Hello
While testing our code on DB2 we have encountered a difference in the
behaviour of DB2Driver (com.ibm.db2.jc c.DB2Driver with driverType= 4)
compared to the drivers offered by Oracle 9i and Sybase SQL Anywhere 7.
Our system contains code like this (java pseudocode)
Connection con = <>
con.setAutoComm it(false);
PreparedStateme nt psel = con.prepareStat ement(<select from table A
where...>);
...
ResultSet res = psel.executeQue ry();
while (res.next())
{
boolean success = <Perform various inserts and updates in other tables
than table A>;
if (success)
con..commit();
else
con..rollback() :
}
...
try{con.setAuto Commit(true);}c atch (Exception err){}
The purpose of this structure is to catch and rollback errors, but also to
keep processing the remaining lines from the resultset.
This works fine in both Oracle and Sybase. But in DB2 a rollback call causes
the resultset to close.
Why does this happen ? is this behaviour a bug in the DB2Driver ? has it
been fixed ?
We need to decide our next step here, If we can't get DB2Driver to behave
the way we expect,
we have to consider looking at alternative drivers or rewriting out code
(which will be unplesant).
Comments are welcome.
Tor
While testing our code on DB2 we have encountered a difference in the
behaviour of DB2Driver (com.ibm.db2.jc c.DB2Driver with driverType= 4)
compared to the drivers offered by Oracle 9i and Sybase SQL Anywhere 7.
Our system contains code like this (java pseudocode)
Connection con = <>
con.setAutoComm it(false);
PreparedStateme nt psel = con.prepareStat ement(<select from table A
where...>);
...
ResultSet res = psel.executeQue ry();
while (res.next())
{
boolean success = <Perform various inserts and updates in other tables
than table A>;
if (success)
con..commit();
else
con..rollback() :
}
...
try{con.setAuto Commit(true);}c atch (Exception err){}
The purpose of this structure is to catch and rollback errors, but also to
keep processing the remaining lines from the resultset.
This works fine in both Oracle and Sybase. But in DB2 a rollback call causes
the resultset to close.
Why does this happen ? is this behaviour a bug in the DB2Driver ? has it
been fixed ?
We need to decide our next step here, If we can't get DB2Driver to behave
the way we expect,
we have to consider looking at alternative drivers or rewriting out code
(which will be unplesant).
Comments are welcome.
Tor
Comment