简体   繁体   中英

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.

这似乎是由于尚未修复的JVM错误造成的:http://bugs.mysql.com/bug.php?id = 62518

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM