2 messages in com.mysql.lists.javaRe: Losing localhost connection?| From | Sent On | Attachments |
|---|---|---|
| Bill Easton | 01 Aug 2002 18:03 | |
| Mark Matthews | 01 Aug 2002 19:13 |
| Subject: | Re: Losing localhost connection?![]() |
|---|---|
| From: | Mark Matthews (ma...@mysql.com) |
| Date: | 08/01/2002 07:13:02 PM |
| List: | com.mysql.lists.java |
On Thu, 2002-08-01 at 20:03, Bill Easton wrote:
I'm seeing occasional failures accessing MySQL via JDBC using localhost. The message (see below) is "Communication link failure," which means any Exception other than EOFException when org.gjt.mm.mysql.MysqlIO reads the first byte of a packet from the server.
I don't understand why this is happening with localhost. If it were an external connection, I could understand the connection dropping. I can produce the same message by stopping and restarting the MySQL service or, presumably, by waiting 8 hr. for the thread to get killed--but this happens with a connection that's a few minutes old.
Using MySQL 3.23.49-nt and mm.mysql-2.0.12. The problem is occurring on Windows ME 4.90. The problem is happening for one user; there are a bunch of users who have not reported this problem.
Traceback follows--it happens when the prepared statement is either UPDATE or SELECT.
java.sql.SQLException: Communication link failure: java.net.SocketException at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java:509) at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java:592) at org.gjt.mm.mysql.Connection.execSQL(Connection.java:1264) at org.gjt.mm.mysql.PreparedStatement.executeQuery(PreparedStatement.java:377)
Any ideas would be appreciated.
Has this connection been idle for some time before it throws this exception? If so, MySQL has probably closed it because of inactivity. You can get around this by adding "autoReconnect=true" to your URL, and MM.MySQL will "ping" the server before each query, and reconnect if the connection is down (easier, but less efficient), _or_ you can catch the exception and look for the SQLState "08S01", which is always present when there is a communications problem, and do the reconnection yourself (harder, but more efficient).
Otherwise I would say this machine has a flaky loopback interface (the TCP/IP stack in dos-based windows (95/98/ME) is known to be pretty poor).
-Mark




