Ask a Question related to IBM DB2, Design and Development.
-
Ralf Assmann #1
Commit on closing connection?
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
Ralf Assmann Guest
-
Closing connection of one user..
now i'm busy with this sharedball thing, so each one that connects gets his own ball.. (with attach function) but now i want do de-attach when... -
Closing an ASP connection
I have used DW to generate the ASP code as I do not know much about it other than the code that I have seen DW generate. My hosting server... -
Closing one active ODBC connection
We run CF MX 7 (multi server) on Windows 2003. We have a data source that connects to RedBrick (RB) database. When we shutdonw RB for maintenance,... -
closing a DB connection? ASP/VBScript
Hi, A page on a site I have taken over has the following: <% myid = request.querystring("id") anyname="SELECT * from fleeces WHERE... -
Closing Database Connection
Hi Does any one know how to close a database connection in dreamweaver (I am using sql server and asp vbscript). My connection script is as...



Reply With Quote

