Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DB2: result set is closed

843859Jul 24 2007 — edited Jul 25 2007
Hi,

I have a DB2 db as source and an Informix DB as target db.
I have something like this:
String sourceSql = "SELECT x FROM y";
ResultSet rs = ...;
Connection targetConn = ...;
PreparedStatement ps = null;
while(rs.next()) {
  Long x = rs.getLong("x");
  String targetSql = "INSERT INTO y (x) VALUES (?)";            
  ps = targetConn.prepareStatement(targetSql);
  ps.setLong(1, x);
  ps.executeUpdate();
  ps.close();
}
targetConn.close();
rs.close();
The program breaks with an "com.ibm.db2.jcc.c.SqlException: [ibm][db2][jcc][10120][10898]".
I tried the createStatement for the DB2 db with different parameters for resultSetType and resultSetConcurrency, but no success. The number of lines inserted are dependent on the settings of the parameters. But it never finished. If I do no inserts, e.g. simple console outputs in the loop, it works. The weird thing is, it seems to be a timing problem, e.g. the number of lines successfully inserted depends on wether it runs in debug mode or not.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 22 2007
Added on Jul 24 2007
1 comment
193 views