Bug #61940 Facing "Java.sql.SQLException: No operations allowed after connection closed."
Submitted: 21 Jul 2011 8:40 Modified: 21 Jul 2011 9:36
Reporter: Kedar Nandimath Email Updates:
Status: Unsupported Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.1.12 OS:Any
Assigned to: CPU Architecture:Any

[21 Jul 2011 8:40] Kedar Nandimath
Description:
i have been going through few forums as i have been facing "Java.sql.SQLException: No operations allowed after connection closed." problem

let me tell the senario.

I m using My Sql version 5.1.47 and Connector/J  (mysql-connector-java-3.1.12-bin.jar)

Code for getting connection object is in servlet's dopost method. and code for closing connection is in finally.

when two user send request at different time. code gets executed successfully
but When two user sends request at same time i.e same hour,min,sec

one request gets completely processed and for other request when code tries to access DB table i m getting following error.

Java.sql.SQLException: No operations allowed after connection closed.

in one of thread i read about nightly build(snapshot) of 3.0.x connector driver and i tried to find it. but i couldn't get it

could you please tell me the reason why connection is getting closed.

and if possible could you send me nightly build(snapshot) of 3.0.x 

or is there other version of connector which takes care of above problem.

How to repeat:
As this is production issue and get created very rarely

instruction for repeating the bug can not be given.
[21 Jul 2011 8:51] Tonci Grgin
Hi Kedar and thanks for your report.

Two things to note:
  o c/J 3.1 is long deprecated and, thus, not supported.
  o Things might be thread safe but that does not mean they are sharable across threads.

So, please check your code and fix the race condition and upgrade to newer c/J.
[21 Jul 2011 9:36] Kedar Nandimath
Hi tonci,

to be on safer side i put all code in synchronized block still i got 

"Java.sql.SQLException: No operations allowed after connection closed." 

could you please tell me which c/j is recommended and what could be the cause for 

exception
[11 Oct 2011 12:33] Tonci Grgin
Kedar, we always recommend latest version. As for the error, you probably work on a connection from one thread while closing same connection from other.