This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Mysql + Tomcat issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Mysql + Tomcat issue" Watch "Mysql + Tomcat issue" New topic

Mysql + Tomcat issue

San Muthu

Joined: Sep 06, 2012
Posts: 3

I have a web application running in Tomcat Server (6) which uses the Mysql DB(5.5) in Solaris SPARC machine. It runs fine when i start the server but next day when i check it seems db connection gets closed (though the server and mysql service is running) and i'm getting the below exception. How to resolve this?

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:


MESSAGE: Communications link failure due to underlying exception:


at com.mysql.jdbc.MysqlIO.readFully(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.Connection.execSQL(
at com.mysql.jdbc.Connection.execSQL(
at com.mysql.jdbc.Statement.executeQuery(

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17282

We can't tell anything about how your program is using the connection. Is it coming from a connection pool or hard-wired into the application (which is not recommended)? Are you opening/obtaining the connection with the expectation that you can talk to it any time you want, or getting it only when you are planning to use it immediately?

Database connections are fairly expensive. They tie up a limited number of resources on the database server. For this reason, most connections eventually time out and disconnect from the server. A properly-configured database connection pool properly used by the webapp(s) can deal with that.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Mysql + Tomcat issue
jQuery in Action, 3rd edition