I have a Db2 return procedure that returns a cursor for one of the tables.
This procedure is called from my java code and truth to retrieve the cursor as a result set and to have a SQLexception exception log,
com.ibm.db2.jcc.am.jo: [jcc][t4][10335][10366][4.7.85] Invalid operation: Connection is closed. ERRORCODE=-4470, SQLSTATE=08003 at com.ibm.db2.jcc.am.dd.a(dd.java:666) at com.ibm.db2.jcc.am.dd.a(dd.java:60)
I searched for a solution for this exception and found this solution on the ibm website, which suggests changing the log configuration,
Increase log file size and number of primary and secondary log files. You can also change the num_log_span value.
Here is an example procedure
CREATE OR REPLACE PROCEDURE ABC(c_dump OUT SYS_REFCURSOR) IS BEGIN open c_dump FOR select feild1,feild1,.... from RSPNSE_TABLE; END;
The following is the Java code,
public void callStoredProc(){ Connection dbConnection = null; CallableStatement callableStatement = null; ResultSet rs = null; String proc = "{call ABC(?)}"; try { dbConnection = connection; callableStatement = dbConnection.prepareCall(proc); callableStatement.registerOutParameter(1, DB2Types.CURSOR);
Now this Java code breaks into this line callableStatement = dbConnection.prepareCall(proc);
Note: Although the exception log contains the text βConnection closedβ, I want to mention that I successfully established a connection with normal database extraction using JDBC, it has no problems.
Jbaba source share