Returned ResultSet is closed...


General J2EE: Returned ResultSet is closed...

  1. Returned ResultSet is closed... (3 messages)

    Hi All.

    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++)
    if (callableStmt.getMoreResults(Statement.KEEP_CURRENT_RESULT))
    resultSet = callableStmt.getResultSet();

    String string = callableStmt.getString(1);

    if(resultSet != null)
    while (
    … do something

    When this executes, I get an "Object is closed" exception at 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.


    Threaded Messages (3)

  2. Returned ResultSet is closed...[ Go to top ]

    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.
  3. Returned ResultSet is closed...[ Go to top ]

    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).

  4. Returned ResultSet is closed...[ Go to top ]

    Exactly... that MS &*[email protected]#^[email protected] it takes a really foolish client to interface Java with MSSQL... thanks anyway.