4 Replies Latest reply on Dec 18, 2007 1:14 AM by David Roberts

    mysql connection reset

    tomerbd2 Newbie

      I'm using cmp2.1 + jdbc and i get from time to time (daily) a connection reset exception.
      im using mysql: 5.0.26 and i made sure that the wait_timeout parameter of mysql is longer than the connection idle timeout of jboss connection pool.

      Can anyone advise please?

      Exception: Communication link failure: java.net.SocketException, underlying cause: Connection reset


      MESSAGE: Connection reset


      java.net.SocketException: Connection reset
      at java.net.SocketInputStream.read(SocketInputStream.java:168)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
      at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
      at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1316)
      at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1463)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1854)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1109)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1203)
      at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1164)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2087)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2037)
      at com.mysql.jdbc.Statement.execute(Statement.java:900)
      at org.jboss.resource.adapter.jdbc.WrappedStatement.execute(Unknown Source)

        • 1. Re: mysql connection reset
          tomerbd2 Newbie

          also note that im using autoReconnect=true

          • 2. Re: mysql connection reset
            David Roberts Apprentice

            Did you ever manage to sort this out?
            I am currently using Jbpm 3.2.2, MySQL 5.027, mysql-connector-java-5.0.3, and Tomcat 5.028. That exception also occurs daily. Anyone have any ideas on what is causing it?

            • 3. Re: mysql connection reset
              Dmitry Trunikov Newbie

              Hi tomerbd2!
              Below is a fragment from J/Connector manual about parameter autoReconnect :

              Should the driver try to re-establish stale and/or dead connections? If enabled the driver will throw an exception for a queries issued on a stale or dead connection, which belong to the current transaction, but will attempt reconnect before the next query issued on the connection in a new transaction. The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, investigate setting the MySQL server variable "wait_timeout" to some high value rather than the default of 8 hours.

              As stated use parameter autoReconnect is a bad practice. I think you should tune value of a tag idle-timeout-minutes in your data source descriptor. A description/example of how to do that is here.
              Also tags check-valid-connection-sql and new-connection-sql could be useful.
              Below is an example of a data source descriptor:



              <check-valid-connection-sql>select 1</check-valid-connection-sql>
              <new-connection-sql>select 1</new-connection-sql>

              • 4. Re: mysql connection reset
                David Roberts Apprentice

                I managed to sort out the dropped connection problem. I posted my solution on this thread: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=105658