Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Communication link failure: java.net.SocketException

 
Tony May
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
Hope someone can help as I'm completely stuck. I am using the Struts framework and am configuring a org.apache.commons.dbcp.BasicDataSource as a connection pool connecting to mySQL 3.23 database.
Everything is fine for a day or so and then I get the following error when trying to access the database -
java.sql.SQLException: Communication link failure: java.net.SocketException
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:882)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:917)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1806)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1740)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1220)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:162)

I am using mySQL-connector-java 3.0.6 drivers and I think I am closing all my connections correctly. What is going wrong ?
 
Tony May
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved it -
The driver kills connections after 8 hours. I wasn't using the autoReconnect=true parameter which should solve the problem.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Moving to the JDBC forum - so that others may share the benefit of your experience .
 
Vikas Aggarwal
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using the DBPool package with a MySQL db under Struts and Tomcat 4.1
with the following settings in the properties file:
drivers=org.gjt.mm.mysql.Driver
logfile=dblog.txt
local.url=jdbc:mysql:/localhost/billblac_recovery
local.user=billblac_bill
local.password=wgb
local.maxpool=20
local.maxconn=20
local.expiry=0
local.name=recovery
local.debug=true
I'm getting the following error message intermittently on the host's linux
server. I don't get the error on my Win2000 desktop under
development:
UserFactory.searchReturn() - EXECUTING STATEMENT
UserBeanCommandFactory.searchReturn() sqlException: Communication link
failure: java.net.SocketException
java.sql.SQLException: Communication link failure: java.net.SocketException
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:882)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1809)
at
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1458)
at
snaq.db.CachedPreparedStatement.executeQuery(CachedPreparedStatement.java:55
)
at com.recovery.factories.UserFactory.searchReturn(Unknown Source)
at com.recovery.actions.LogInAction.execute(Unknown Source)
The error always occurs after about 10 minutes has gone by since the last
connection to the DB has been made. I have to restart
Tomcat on the server to clear it all up. I'm at a loss here and any ideas
would be greatly appreciated!
Also, where does the dblog.txt file go? In the same directory as the
properties file? I am not getting any debug info into the file.
Thanks,
Vikas Aggarwal
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic