-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Chris,
On 10/11/17 5:21 PM, Chris Cheshire wrote: > Working on a migration from 7 to 8.5, and in it I am now using the > tomcat dbcp, instead of apache commons dbcp.> I have found that > with no other changes to the db code (except the factory param for > the resource), it is working fine other than there is an implicit > commit happening when I close a connection, even with autocommit > turned off in mysql config, resource config AND in my code. Your complaint is very close to my heart, here. <3 Back in 2003 or so, I posted roughly this exact question to this mailing list with a little less ... diplomacy, shall we say? > try { this.dbConn = this.dataSource.getConnection(); > this.dbConn.setAutoCommit(false); > this.dbConn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMIT TED); > > } > catch (SQLException ex) { throw new DAOException("unable to get > database connection", ex); } I'll bet you've had this problem for a really long time, but just didn't notice it until now. The core problem is that you have autocommit=false in your configuration and autocommit=true in your code. If an exception occurs and you don't rollback the transaction, the connection pool will reset all of the settings to your configured settings (including autocommit=true). Setting autocommit=true when autocommit=false commits the transaction, which is SUPER surprising to anyone who hasn't read the Javadoc[1] Technically, this happens whether you encounter an exception or not, but it's fairly rare to have code that intentionally does this: conn.setAutoCommit(false); // UPDATE ...; conn.close(); So, given that this is usually an "exceptional" situation, it's your exceptions you need to carefully handle. In fact, you need to do more than you are used to doing. Have a look at this post I did years later when related questions kept coming up on the list: http://blog.christopherschultz.net/index.php/2009/03/16/properly-handlin g-pooled-jdbc-connections/ Hope that helps, - -chris -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlngMBoACgkQHPApP6U8 pFhdjBAAl2u3lxKhrjKdmtjUgtYp0/gOfTPq7jXjdgZBrkSNh9q6I8dJ6gQOsECV TkCQ2LH8tAUpuUYWCt7QJRLQPVAuwrzplue1InlTFCS8I1b/WK7vQk93teB4I0Ia HKaC4RGGtgKgS//PsCRxDdFgo0Hzr+hA+nte1qFytmla8ZRZjimbz5EnWJpNwYoU XjEjhaF6wdVOHP8zKU9/CIc3XQKC1kfQb9Rodb9SZTpjFDTw12NsBjEXG5evY8XJ A2PPxHPiRdyyHq2R1MDWGFWdSdCsY4pFq4nvNExEuIuHg1/C+GlGUENLH3MiJNPY minxeaKykVfmUd2zJvWjxmhrdw8nHT3ThtAHA0BgU7thBCenANFbSBxx7+39Jxg/ eDEW4dEqOP3c/ZvifpMrGxjJ0zXBXDu7Jik4KFEzMWI8oaAl3hSSDwEe7FEJE41Y lDv+LjcBgDwSHLfTbau+0xJx79wAKTAFY7v7uGujUgDZqWsRG1znyZx+OuZnbWxQ JSbQSJ3pOMerybeJMuHx1a4y+HwA4t0GtLigeRMeyFvTqqtfCVasr3ONMh22XYIU OORbLADRwjbqYnswvxRC06FfKvU8AhNwuybt/XzHrTfURuIZWx7GRycMlaEMaUdS OdWlW6Zf3+fWfUxg05zIX3q2Ug4h2O1zW+ccPOrs5bswE9EEAZM= =eyik -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org