commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Blashill" <>
Subject [DbUtils] MySQL rollback problem..
Date Wed, 23 Jun 2004 19:03:35 GMT

I noticed a problem recently where autoCommit set to false did not work
as I intended. Here is my code snippet:

        Connection connection = dataSource.getConnection();
        boolean success = false;

        QueryRunner queryRunner = new QueryRunner();
		queryRunner.update(connection, sqlStatement1);
		queryRunner.update(connection, sqlStatement2);
		queryRunner.update(connection, sqlStatement3);
            success = true;
            if (connection != null)
                if (success)

What I expected from this code was that all three sql statements would
be performed as a transaction - that is, if one fails then the other
will no go through either. However, I have observed that even then
connection.rollback() get called in the event of an error. The updates
that may have already succeeded do NOT get undone. In fact, they
appeared in the database regardless of whether connection.commit() was
called. I have done similar things using Postgres 7.4, but now it does
not seem to work with mySQL. Has anyone else experienced this? I am
using MySQL 4.

Thanks for any input you may have,


FYI, I am using DBCP to do my connection pooling as well.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message