MySQL Forums
Forum List  »  Quality Assurance

sometimes lost connection with mysql (connection timeout)
Posted by: Esvet Email
Date: May 30, 2008 02:58AM

Hi,

I got a problem. I wrote an applet application and it uses mysql database. It successfuly connects to the mysql database and store/recieve some data. While testing as a user, I request the web page with the applet and keep it running for several hours to do some reading and storing data to mysql database. What I have noticed is that sometimes I can not connect to mysql database for some seconds (1 or 2 or 3 seconds or a even more).

MySql is running on linux. If the requested applet is demanded and running on windows the connection is much more frequently lost then if it is running on linux.

What is wrong? Why while sometimes connecting to mysql database the connection can't be done?

I set the connectTimeout property to 3 and autoReconnect to true. This is the exception I am getting sometimes while connecting to the database (it says connect timed out):

"com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Server connection failure during transaction. Due to underlying exception: 'java.net.SocketTimeoutException: connect timed out'.

** BEGIN NESTED EXCEPTION **

java.net.SocketTimeoutException
MESSAGE: connect timed out

STACKTRACE:

java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:520)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:329)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2921)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at app.db_app.IsthereAConnection(db_app.java:128)
at app.app$Watch.run(app.java:924)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)


** END NESTED EXCEPTION **


Attempted reconnect 3 times. Giving up."


Regards,
Esvet



Edited 3 time(s). Last edit at 05/30/2008 03:14AM by Esvet Email.

Options: ReplyQuote


Subject
Views
Written By
Posted
sometimes lost connection with mysql (connection timeout)
16733
May 30, 2008 02:58AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.