-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Richard Hyatt wrote:
| If an application uses autoReconnect but disables autoCommit, then the
| jdbc driver will fail to reconnect with the database. This can be
| demonstrated by setting the wait_timeout on mySQL to 30 seconds, open a
| connection with the above options and wait 40 seconds after the
| connection is open to execute a query.
|
| Examining the source for the driver (3.0 and 3.1) it is visible that
| without autoCommit the database connection cannot be re-established:
|
| Looking at the mySQL jdbc code (from com.mysql.jdbcConnection.java ~
| line 1788):
|
| if ((this.highAvailability || this.failedOver) && this.autoCommit) {
| try {
| ping();
| } catch (Exception Ex) {
| createNewIO(true);
| }
| }
|
| I have modified and tested the following code change and it appears to
| fix the problem:
|
| if ( this.highAvailability || (this.failedOver && this.autoCommit) ) {
| try {
| ping();
| } catch (Exception Ex) {
| createNewIO(true);
| }
| }
|
| Many mySQL users currently fix the problem by setting autoCommit to true
| (which may be undesirable) or increasing the wait_timeout value to a
| very large number (which violates the design of the timeout feature).
This is documented in the README that comes with 3.0.6, and there is a reason for it!
If you don't do it this way, you stand to corrupt your database, as you will reconnect, and proceed with the remainder of a transaction that was rolled back automatically when you lost the connection :(
You can not automatically re-connect when you are using transactions. Your application will have to be 'smart' enough, to re-start the transaction _from_the_beginning_. This also only works if you're using _only_ transactional tables...Otherwise, your code will have to be smart enough to check what has already been done, so that data does not get corrupted.
-Mark
- -- MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/
For technical support contracts, visit https://order.mysql.com/?ref=mmma
~ __ ___ ___ ____ __ ~ / |/ /_ __/ __/ __ \/ / Mark Matthews <[EMAIL PROTECTED]> ~ / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java ~ /_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA ~ <___/ www.mysql.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+ivsFtvXNTca6JD8RAkzFAKCF7VgQFkP9cYQsjzg9TgPh8iDb2wCeLNmc h4FaXIqzWN2CBQjJWs3hRw0= =dDLN -----END PGP SIGNATURE-----
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
