I have an issue with JDBC. I have a Stored Proc that returns both output parameters and a ResultSet, which I am calling through a CallableStatement. This is my code:
for (int i=0; i<10; i++)
resultSet = callableStmt.getResultSet();
String string = callableStmt.getString(1);
if(resultSet != null)
When this executes, I get an "Object is closed" exception at resultSet.next(). When I do callableStmt.getString(1) after I finish processing the ResultSet, everything goes well. But there it is mandatory for me to get the output parameter before I process the ResultSet. In fact, whether or not I process the ResultSet is dependant on the output parameter.
I am working on MSSQL Server 2000, using MSSQL drivers. I tried using DataDirect driver also, but with no improvements. Please tell me if this is a problem with the driver implementation or is a normal behavior of JDBC. Thanks.
From the Java API docs for CallableStatement:
"For maximum portability, a call's ResultSet objects and update counts should be processed prior to getting the values of output parameters."
So I guess this might be behaviour that you could expect to see with some vendors at least.
From what I remember when working with SQL Server with other APIs (old ADO mainly), it has never been possible to retrieve the value of OUT parameters before finishing with the resultset(s). This is not an issue with some other DBMS (Oracle, for example).
Exactly... that MS &*[email protected]
it takes a really foolish client to interface Java with MSSQL... thanks anyway.