List:MySQL and Java« Previous MessageNext Message »
From:Mark Matthews Date:January 21 2003 4:47pm
Subject:Re: AutoReconnect problem
View as plain text  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pål Arne Hoff wrote:
> I have a autoReconnect problem with Connector/J 3.0.4 (The problem seems 
> to be in 3.0.2 and 3.0.3 too, but I seem to remember not having the 
> problem with 3.0.1).
> 
> I'm running MySQL Max 3.23.54a in Linux, using JBoss 2.4.10 and JRockit 
> 7.0 JVM (I also tested with Sun's JVM 1.4.1_01 and JRockit 8.0b).
> 
> I connect to MySQL through JBoss using this URL: 
> jdbc:mysql://localhost/bms_company?autoReconnect=true. Then every 
> morning when the connection hasn't been used over night, I get a 
> NullPointerException when I try to connect through our application. The 
> same thing happens if I restart MySQL without restarting JBoss. If I 
> change to mm.mysql-2.0.14, everything works just fine.
> 
> Is this a bug in the new driver?

Someone else with a similar problem has brought something to my 
attention that I should have warned you about. Are you setting 
autoCommit(true) at the end of every transaction? The later versions of 
the driver do not allow autoReconnect when autoCommit is false, because 
it could lead to a non-transactional state. It is only safe to reconnect 
when autoCommit=true. If you setAutoCommit(true) after you 
commit/rollback a transaction, and then set it to 'false' when you 
begin, you should get the behavior you desire.

If you're using a connection pool, it should be doing this for you, as 
the JDBC spec states that autoCommit='true' is the default state for all 
new connections, and connection pools, even though re-using existing 
connections, should set the default state of the connection so that it 
appears to be a 'new' one.

	-Mark

- -- 
MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/

For technical support contracts, visit https://order.mysql.com/?ref=mmma

     __  ___     ___ ____  __
    /  |/  /_ __/ __/ __ \/ /  Mark Matthews <mark@stripped>
   / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
  /_/  /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
         <___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+LWuotvXNTca6JD8RAvkfAKC6J1iXQpaKaBg8MPwq/9TDlbxfuwCgnxOq
9nRbli2zXfDE9A+OIYfqBEI=
=MjBK
-----END PGP SIGNATURE-----

Thread
AutoReconnect problemPål Arne Hoff21 Jan
  • Re: AutoReconnect problemmmatthew21 Jan
  • Re: AutoReconnect problemMark Matthews21 Jan
    • Re: AutoReconnect problemPål Arne Hoff23 Jan