Retrieving Stored Procedure Returns

X

Xeth Waxman

Greetings experts. I'm having a problem retrieving values from a
CallableStatement after executing a Stored procedure. The RDBMS is MS
SQL Server 2k and the JDBC driver is JTDS 0.8.1. Here's the code I
have:

cs = con.prepareCall("{call spGetNextBatch(?,?,?,?,?,?,?,?,?)}");

cs.registerOutParameter(7, Types.INTEGER);
cs.registerOutParameter(8, Types.INTEGER);
cs.registerOutParameter(9, Types.INTEGER);
cs.setString(1, "GCC");
cs.setInt(2, 8);
cs.setInt(3, 802);
cs.setString(4, userName);
cs.setString(5, batchComment);
cs.setString(6, todayString);

//everything's set - execute
cs.execute();

while (cs.getMoreResults() == true && cs.getUpdateCount()!= -1)
{
//processing stuff
System.out.println("sizzling shizzle");
}

//get our values out
int batchKey = cs.getInt(7);
int nextBatchNo = cs.getInt(8);
int retVal = cs.getInt(9);

According to the profiler, the SP is executing and returning the
appropriate values. However, after running this code, all three value
(batchKey, nextBatchNo , and retVal) are all unitialized (0), which is
incorrect. I am stumped as to what I should be looking for or fixing,
and as always any assistance is appreciated.
 
B

Bryce

Greetings experts. I'm having a problem retrieving values from a
CallableStatement after executing a Stored procedure. The RDBMS is MS
SQL Server 2k and the JDBC driver is JTDS 0.8.1. Here's the code I
have:

should this be:
cs = con.prepareCall("{? = call spGetNextBatch(?,?,?,?,?,?,?,?,?)}");

the name spGetNextBatch makes the think there's an actual return value
with this stored procedure...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top