JCS
JCS

Reputation: 907

JDBC Socket Exception when closing connection to MySQL

I am connecting to MySQL using the following connection string in JDBC.

jdbc:mysql://127.0.0.1/db?enable-named-pipe&socket=MySQL&socketFactory=com.mysql.jdbc.NamedPipeSocketFactory&zeroDateTimeBehavior=convertToNull

If i use a tcp/ip connection i can close the connection fine but it seems if i use a local socket/pipe connection to MySQL it throws the following exception.

java.netSocketException: Socket is not connected

Seems like the connection is being dropped without me needing to close the connection, so when using a local socket/pipe i don't have to close the connection it is done automatically, am i correct in thinking this? The data i have inserted seems to have gone in fine.

Thanks.

Upvotes: 0

Views: 775

Answers (2)

JCS
JCS

Reputation: 907

It seems to be due to a JVM bug that hasn't been fixed yet http://bugs.mysql.com/bug.php?id=62518

Upvotes: 1

Audrius Meškauskas
Audrius Meškauskas

Reputation: 21778

You know that you have not closed the connection and that you should.

For peace of mind, you may try to close the connection anyway and catch the thrown exception. This may be better than to rely on some kind of bug kind of feature that may go away in the next minor release.

Upvotes: 0

Related Questions