2 Replies Latest reply on May 9, 2003 11:22 AM by sczadzeck

    JDBC/MySQL request timeout configuration

    sczadzeck

      I'm encountering a problem were a request to my database server (MySQL) appears to get no response. Unfortunately JBoss seems to wait indefinitely for a response. I image there's a way to configure a timeout for this situation but can't seems to figure out how to do it. Here's a stack dump of the thread in question:

      "Ring-1" daemon prio=5 tid=0x00A3A5F0 nid=0xa90 runnable [1af8f000..1af8fd8c]
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:129)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
      - locked <038890A0> (a java.io.BufferedInputStream)
      at com.mysql.jdbc.MysqlIO.readPacket(Unknown Source)
      at com.mysql.jdbc.MysqlIO.sendCommand(Unknown Source)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(Unknown Source)
      at com.mysql.jdbc.Connection.execSQL(Unknown Source)
      - locked <02D989A0> (a com.mysql.jdbc.jdbc2.IO)
      at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
      - locked <02D989A0> (a com.mysql.jdbc.jdbc2.IO)
      at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
      at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.executeU
      pdate(LocalPreparedStatement.java:308)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCSto
      reEntityCommand.java:90)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStore
      Manager.java:589)
      at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenc
      eManager.java:458)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.stor
      eEntity(CachedConnectionInterceptor.java:388)
      at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:708)
      at org.jboss.ejb.GlobalTxEntityMap.syncEntities(GlobalTxEntityMap.java:1
      17)
      at org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapCleanup.beforeComple
      tion(GlobalTxEntityMap.java:185)
      at org.jboss.tm.TxCapsule.doBeforeCompletion(TxCapsule.java:1394)
      at org.jboss.tm.TxCapsule.commit(TxCapsule.java:364)
      at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
      torCMT.java:251)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:9
      2)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.
      java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLoca
      lContainerInvoker.java:301)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy34.update(Unknown Source)
      at com.valinsoft.plannine.jmx.Simulator$LocalEntity.update(Simulator.jav
      a:730)
      at com.valinsoft.plannine.jmx.Simulator$Ring.run(Simulator.java:1000)
      at java.lang.Thread.run(Thread.java:536)

      "JBoss Life Thread" prio=5 tid=0x1B94E2B8 nid=0xf3c in Object.wait() [1c3bf000..
      1c3bfd8c]
      at java.lang.Object.wait(Native Method)
      - waiting on <02C93CB8> (a java.lang.Object)
      at java.lang.Object.wait(Object.java:426)
      at org.jboss.system.server.ServerImpl$1.run(ServerImpl.java:338)
      - locked <02C93CB8> (a java.lang.Object)

      "StandardManager[/jmx-console]" daemon prio=5 tid=0x1B8B2A90 nid=0xda8 waiting o
      n condition [1c37f000..1c37fd8c]
      at java.lang.Thread.sleep(Native Method)
      at org.apache.catalina.session.StandardManager.threadSleep(StandardManag
      er.java:780)
      at org.apache.catalina.session.StandardManager.run(StandardManager.java:
      839)
      at java.lang.Thread.run(Thread.java:536)

      Any help will be greatly appreciated.

      Thanks,
      Scott

        • 1. Re: JDBC/MySQL request timeout configuration
          sczadzeck

          Answered my own question. For others the following parameter can be configured in the 'connection-url' tag in mysql-ds.xml (see the MySQL Connection/J readme file for a all the configurable parameters):

          socketTimeout - When set to something other than '0' (the default), the driver will throw a SQLException when this timeout (in ms) has expired, and invalidate (close) the connection. The SQLState when this happens will be "08S01", just as when communication fails for other reasons. Your application should have code to recover from this event (by creating a new connection, for example)

          For example:
          <connection-url>jdbc:mysql://localhost:3306/nemesis?autoReconnect=true?socketTimeout=5000</connection-url>

          • 2. Re: JDBC/MySQL request timeout configuration
            sczadzeck

            Answered my own question. For others the following parameter can be configured in the 'connection-url' tag in mysql-ds.xml (see the MySQL Connection/J readme file for a all the configurable parameters):

            socketTimeout - When set to something other than '0' (the default), the driver will throw a SQLException when this timeout (in ms) has expired, and invalidate (close) the connection. The SQLState when this happens will be "08S01", just as when communication fails for other reasons. Your application should have code to recover from this event (by creating a new connection, for example)

            For example:
            <connection-url>jdbc:mysql://localhost:3306/nemesis?autoReconnect=true?socketTimeout=5000</connection-url>