permaculture playing cards*
The moose likes JDBC and the fly likes Communications link failure due to underlying exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Communications link failure due to underlying exception" Watch "Communications link failure due to underlying exception" New topic
Author

Communications link failure due to underlying exception

Milind Talele
Greenhorn

Joined: Nov 26, 2010
Posts: 4
Hi,

I am getting this exception frequently on console. I have increase Mysql time out period to 8 Hr also but it doesn't work. After restart tomcat it work for some time
again this exceptions come on console.
I am using Tomcat 6 with MySQL, and Torque

===============================================================================
[11/21/10 12:02 AM WARNING] TorqueException while getting the new Connection org.apache.torque.TorqueException: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.io.EOFException

STACKTRACE:

java.io.EOFException
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1963)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2375)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3243)
at com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5371)
at
org.apache.commons.dbcp.cpdsadapter.ConnectionImpl.setAutoCommit(ConnectionImpl.java:326)
at org.apache.commons.dbcp.datasources.SharedPoolDataSource.setupDefaults(SharedPoolDataSource.java:227)
at org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(InstanceKeyDataSource.java:692)
at org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(InstanceKeyDataSource.java:653)
at org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:912)
at org.apache.torque.Torque.getConnection(Torque.java:314)
at org.apache.torque.util.Transaction.beginOptional(Transaction.java:108)
at com.company.framework.model.util.TorqueUtility.getNewConnection(TorqueUtility.java:712)
at com.company.cs.allocation.job.alert.WSAlertSYProfileLoader.loadProfile(WSAlertSYProfileLoader.java:161)
at com.company.framework.alert.JobSYProcessing.csJobExecute(JobSYProcessing.java:70)
at
com.company.framework.jobutility.csJobThread.run(csJobThread.java:137)


** END NESTED EXCEPTION **

Last packet sent to the server was 0 ms ago. -> com.company.framework.model.util.TorqueUtility.getNewConnection():718
==================================================================================

After this exception application stop working and on every click it show this exception on console.


Any one have solution on this? please reply.

Thanks in advance.

Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Welcome to JavaRanch, Milind.


OCUP UML fundamental and ITIL foundation
youtube channel
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Milind,
Welcome to CodeRanch!

There are a few timeouts you may have to look at. One is the database timeout which you looked at. There's also a transaction timeout set on the application server. And if your database is on the network, you may have a firewall timeout.

A question though - do you have a giant database operation or is this just happening on small operations from time to time? If the later, you should check your connection pool settings. The min size might be too high. Another approach is to try to get the connection a second time on failure.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Milind Talele
Greenhorn

Joined: Nov 26, 2010
Posts: 4
Hi,

1. Do you means transaction setting in Tomcat? Where it is ?
2. I am using below setting in "torque.properties". maxWait = 2000.
3. When I got exception I tried to get new connection which also rise same exception means torque it is not allowing to give new connection itself.
4. I think this is not a code level issue. May be I am missing some setting on MySQL/ Tomcat side.

== torque.properties ==
torque.applicationRoot = .
torque.database.default=csa
torque.database.csa.adapter=mysql
torque.dsfactory.csa.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory
torque.dsfactory.csa.connection.driver = org.gjt.mm.mysql.Driver
torque.dsfactory.csa.connection.url = jdbc:mysql://localhost:3306/Matrix?autoReconnect=true&zeroDateTimeBehavior=convertToNull
torque.dsfactory.csa.connection.user = root
torque.dsfactory.csa.connection.password = root
torque.dsfactory.csa.pool.maxIdle = 20
torque.dsfactory.csa.pool.maxWait = 2000
torque.idbroker.cleverquantity=true
torque.manager.useCache = true
=============================
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

I was thinking you were using a connection pool defined on the Tomcat level. Since you are defining it via Torque, it might not apply. Did you set up a <Resource> in your Tomcat config as described here?
Milind Talele
Greenhorn

Joined: Nov 26, 2010
Posts: 4
Hey,

By upgrading below

a) dbcp commons library
b) connection pool library
c) mysql j/connector library.

I fixed issue.
Milind Talele
Greenhorn

Joined: Nov 26, 2010
Posts: 4

Hi,

I found solution on http://communications-link-failure.blogspot.com

I tried it and it is working for me.

Thanks
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Milind,
what was the solution? Your post about upgrading the libraries, or the steps in that blog?
I am confused because you report that two different solutions fixed that issue
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Communications link failure due to underlying exception
 
Similar Threads
another JDBC driver question
Broken pipe Error
Visibility help?
Why I get CommunicationsException using Quartz JobStore web application ?
Communications link failure in JBOSS