Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 sql server store procedure return values

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-02-28 : 08:05:42
chandra writes "Hello SqlTeam,

Here in the following code . I am not under standing how the protected items are getting from the sql the java code.could u plz tell.

Here Ever Resource have more than one proteced items.


Java Code:
________________
public Hashtable getResourceInfo(String resourceId)
throws SQLException,
InvalidParameterException,
DuplicatedRowsException,
OtherException
{
int rc, count = 0;
CallableStatement cstmt = null;
Hashtable resInfo = null;
String tmp, tmpList[], protectedItems[];

tmpList = new String[m_db.getMaxFetch()];
Connection conn = null;

try
{
conn = m_db.getSQLConnection();
cstmt = (CallableStatement) conn.prepareCall("{call RES_get_resource(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}");
cstmt.setString(1, resourceId);
cstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(3, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(4, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(5, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(6, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(7, java.sql.Types.TIMESTAMP);
cstmt.registerOutParameter(8, java.sql.Types.TIMESTAMP);
cstmt.registerOutParameter(9, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(10, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(11, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(12, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(13, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(14, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(15, java.sql.Types.INTEGER);
cstmt.execute();

while (true)
{
ResultSet rs = cstmt.getResultSet();
int updateCount = cstmt.getUpdateCount();

if (rs == null && updateCount == -1)
break;

if (rs != null)
{
while (rs.next())
{
tmpList[count] = new String(rs.getString(1));
count++;
}

rs.close();
}
cstmt.getMoreResults();
}

protectedItems = new String[count];

for (int i = 0; i < count; i++)
{
protectedItems[i] = tmpList[i];
}

rc = cstmt.getInt(15);

if (rc == 0)
{
resInfo = new Hashtable();
resInfo.put("server_id", new String(cstmt.getString(2)));

tmp = cstmt.getString(3);
if (tmp != null)
resInfo.put("category_id", new String(tmp));
else
resInfo.put("category_id", new String(""));

resInfo.put("resource_name", new String(cstmt.getString(4)));
resInfo.put("resource_descn", new String(cstmt.getString(5)));

tmp = cstmt.getString(6);
if (tmp != null)
resInfo.put("global_resource_indicator", new String(tmp));
else
resInfo.put("global_resource_indicator", new String(""));

resInfo.put("created_date",
new String(cstmt.getTimestamp(7).toString())
   

- Advertisement -