Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Using OracleConnectionCacheImpl together with statement caching
I'm using Oracle's JDBC 8.1.7 driver, which has an implementation of
connection pooling (OracleConnectionCacheImpl) I have problem with
combining this caching implementation with statement caching, which
should be enabled after using the setStmtCacheSize() method in the
OracleConnectionCacheImpl object.
The following code runs in loop (occi is OracleConnectionCacheImpl object):
private void doPreparedStatement(int clipID) throws SQLException {
// get connection from the pool
Connection con = this.occi.getConnection();
// create prepared statement
PreparedStatement ps = con.prepareStatement("select clipTitle from
CLIPS where clipID=?");
// execute the query
ps.setInt(1,clipID);
ResultSet rs = ps.executeQuery();
while ( rs.next() ) {
String sClipTitle = rs.getString("ClipTitle"); System.err.println("ClipTitle is: "+sClipTitle);}
// return connection to the pool
con.close();
}
after the second time it runs, i'm getting the following exception in the rs.next() line :
java.sql.SQLException: Closed Connection: next
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:185)
at i3_testings.db.CheckDB.doPreparedStatement(CheckDB.java:46)
at i3_testings.db.CheckDB.main(CheckDB.java:62)
Exception in thread "main"
Can't find the problem, please help
Thanks in advanced
Amos
Received on Wed Jan 02 2002 - 09:58:35 CST