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
-Peter