Bug #61707 MySQLNonTransientConnectionException: Connection.close() has already been called
Submitted: 30 Jun 2011 13:22 Modified: 30 Jun 2011 15:29
Reporter: sube singh Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:5.0.4 OS:Solaris
Assigned to: CPU Architecture:Any
Tags: Connection.close() has already been called, Connection.close() has already been called

[30 Jun 2011 13:22] sube singh
Description:
Could you please suggest what is the reason for below given exception as soon as possible.

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)
	at com.mysql.jdbc.Connection.getMutex(Connection.java:3640)
	at com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5243)
	at com.mchange.v2.c3p0.impl.NewProxyConnection.setAutoCommit(NewProxyConnection.java:88

C3P0 setting
------------
   factory="org.apache.naming.factory.BeanFactory" 
                type="com.mchange.v2.c3p0.ComboPooledDataSource" 
                jdbcUrl="jdbc:mysql://localhost/mdsdb?autoReconnect=true"
                minPoolSize="10" 
                maxPoolSize="50" 
                acquireIncrement="5" 
                numHelperThreads="50"
                maxAdministrativeTaskTime="1200"
                maxIdleTime="2700" 
                maxIdleTimeExcessConnections="300"
                idleConnectionTestPeriod="600" 
                debugUnreturnedConnectionStackTraces="true"
                unreturnedConnectionTimeout="600

How to repeat:
xyz
[30 Jun 2011 13:27] Valeriy Kravchuk
What exact version of Connector/J, 5.1.x, do you use?
[30 Jun 2011 13:30] sube singh
version: mysql-connector-java-5.0.4
[30 Jun 2011 13:38] Valeriy Kravchuk
Can you check with a newer version, 5.1.16?
[30 Jun 2011 13:44] sube singh
I can try it. Could you please explain what is the root cause of problem?
[30 Jun 2011 13:54] Tonci Grgin
Hi Sube.

It's a pools responsibility to check the connections it's dealing out to application and make sure they are still valid. In this case it certainly look slike C3P0 did not do it's job. Maybe there's some PING property you can set?
[30 Jun 2011 14:58] sube singh
Hi,

Could you please suggest what is the best C3P0 setting for MySQL database with JDBC driver version 5.0.4?

Thanks,
Sube
[30 Jun 2011 15:00] sube singh
If I changes attributes in C3P0,  MySQL db server throwing Apprent DeadLock exception.
[30 Jun 2011 15:30] sube singh
.
[30 Jun 2011 15:30] sube singh
.