java.sql.SQLException: Closed Statement when using PreparedStatement
Hello all,
I'm attempting to execute two prepared statements from the same connection and everytime I do I get this error:
java.sql.SQLException: Closed Statement
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
at oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:47
68)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePrepar
edStatement.java:349)
at com.knowledgecc.coplink2.Admin.AdminProcedures.updateUsersPrefer(Admi
nProcedures.java:2261)
This is the code that is being used:
sql1 and sql2 are different sql statements
Connection con = null;
con = ConnectionPoolMgr.getConnection(connectionType);
PreparedStatement prestmtDel = con.prepareStatement(sql1, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
prestmtDel.setString(1, user.getUserName());
prestmtDel.setString(2, formName + ".%");
prestmtDel.executeUpdate();
prestmtDel.close();
PreparedStatement prestmtInsert = con.prepareStatement(sql2, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
prestmtInsert.setString(1, user.getUserName());
prestmtInsert.setString(2, formName + "." + name);
prestmtInsert.setString(3, value);
prestmtInsert.executeUpdate();
prestmtInsert.close();
ConnectionPoolMgr.freeConnection(connectionType, con);
The first prepared statement will query, but the second throws the exception on the executeUpdate line. I'm using the brand new (downloaded today) Oracle 9i driver. The Connection is created as a regular connection - not an OracleConnection. Is this because of the Implicit Caching? Is the driver giving me logical connections instead of physical ones? This code DOES work with other drivers of other databases....
I've searched through the forums but never really found any answers that address this problem directly (though there are some people who seem to have the same problem I do). Any and all help is greatly appreciated....
Thanks in advance
--Andy