Hi there,

using a Java program on OS390 and DB2 version 7, we have the following
problem:

After creating a connection using "setAutoCommit(false)", we do some
updates on the database. If all updates have been done, a commit is
sent to the database. All this works well.

If we make the update on the database without sending a (manual)
commit to the database and closing our connection, the updates are
also commited even if we did not call "connection.commit()". We have
always thought that the database will do a rollback if the connection
will be closed without sending a commit, but this seems not to be
true.

The code we use looks like this:

// Getting a connection
Connection con = ...;

// turn off auto commit
con.setAutoCommit(false);

// creating prepared statements
PreparedStatement preparedStatement = ...;

try
{
preparedStatement.executeUpdate("<sql command 1>");
preparedStatement.executeUpdate("<sql command 2>");
preparedStatement.executeUpdate("<sql command 3>");
}
catch (Exception e)
{
try
{
con.rollback();
}
catch (SQLException e)
{
// Logging information
}
}
finally
{
con.close();
}

If no exception occurs, the finally block will be reached after
executing the updates. After the connection is closed and no
"connection.commit()" was called, all the updates made in the
try-block are commited in the database.

Is there any global setting of DB2 version 7 on OS390, where can be
defined if a rollback should be called on closing a connection or a
commit? If there is such a global setting, where can we find it and
how is it called?

Many thanks for your answers.

We are looking forward to hearing from you as soon as possible.

Best regards



Ralf