Simon Haldon wrote:
> Was this ever resolved? I am passing the same
> connection object to a chain of queries and it
> suddenly gives this error, after successfully
> executing half a dozen queries that reference the
> self same connection object.
>
> The error occurs seemingly at random.
>
> If idle connections are closed after 8 hours, fine
> - but this connection has just been used several
> times in the last few milliseconds. Why would it
> then time out? If someone can clarify this I'd be
> grateful, I have started coding retry logic in all
> my methods that exec preparedstatements, but I
> would like to understand exactly what is going
> on.
>
> I have autoreconnect=true in my connection string.
> It's MySQL 4.1.16, connector/J 3.1.7.
>
> Here's my error down to the preparedstatement
> call:
>
> com.mysql.jdbc.CommunicationsException:
> Communications link failure due to underlying
> exception:
>
> ** BEGIN NESTED EXCEPTION **
>
> java.net.SocketException
> MESSAGE: Broken pipe
>
> STACKTRACE:
>
> java.net.SocketException: Broken pipe
> at
> java.net.SocketOutputStream.socketWrite0(Native
> Method)
> at
> java.net.SocketOutputStream.socketWrite(SocketOutp
> utStream.java:92)
> at
> java.net.SocketOutputStream.write(SocketOutputStre
> am.java:136)
> at
> java.io.BufferedOutputStream.flushBuffer(BufferedO
> utputStream.java:65)
> at
> java.io.BufferedOutputStream.flush(BufferedOutputS
> tream.java:123)
> at
> com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2616)
> at
> com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2547)
> at
> com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:15
> 12)
> at
> com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java
> :1622)
> at
> com.mysql.jdbc.Connection.execSQL(Connection.java:
> 2376)
> at
> com.mysql.jdbc.Connection.execSQL(Connection.java:
> 2297)
> at
> com.mysql.jdbc.PreparedStatement.executeInternal(P
> reparedStatement.java:1860)
> at
> com.mysql.jdbc.PreparedStatement.executeUpdate(Pre
> paredStatement.java:1957)
> at
> com.mysql.jdbc.PreparedStatement.executeUpdate(Pre
> paredStatement.java:1880)
> at
> com.mysql.jdbc.PreparedStatement.executeUpdate(Pre
> paredStatement.java:1741)
> at
> org.apache.commons.dbcp.DelegatingPreparedStatemen
> t.executeUpdate(DelegatingPreparedStatement.java:1
> 01)
>
> Thanks in advance for any help on this!
You might try a newer connector/J first, 3.1.12 is current. Is your MySQL server co-located on the same host, or is it on the network?
-Mark
Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html