JBoss + MySQL problem


Web tier: servlets, JSP, Web frameworks: JBoss + MySQL problem

  1. JBoss + MySQL problem (4 messages)

    Hi all. Hope that I am not way off posting in this forum. If so please feel free to direct me to the correct one :)

    I have a connection problem. Here goes:

    My setup: JBoss-Tomcat 2.4.1/3.2.3, Mysql 3.23.36, mm.mysql-2.0.4.
    My Scenario: I connect to Mysql through a lookup to a connection defined i jboss.jcml like so:
    <mbean code="org.jboss.jdbc.XADataSourceLoader" name="DefaultDomain:service=XADataSource,name=aDS">
    <attribute name="PoolName">aDS</attribute>
    <attribute name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attribute>
    <attribute name="URL">jdbc:mysql://my-server/my-db</attribute>
    <attribute name="JDBCUser">my-user</attribute>
    <attribute name="MaxSize">0</attribute>
    <attribute name="Password">my-pwd</attribute>
    <attribute name="InvalidateOnError">false</attribute>
    <attribute name="GCEnabled">false</attribute>
    <attribute name="GCInterval">120000</attribute>
    <attribute name="IdleTimeout">18000</attribute>
    <attribute name="IdleTimeoutEnabled">false</attribute>
    <attribute name="LoggingEnabled">true</attribute>
    <attribute name="MinSize">1</attribute>

    My problem is this: Every now and then I get java.sql.SQLException ->"lost connection during query". If I try the action again it usually fails one more time, then works like a charm. It never fails for more than two times in a row, though.

    The mysqld.log indicated that the problem is "Aborted connection XXX to db: 'dbnamn' user: 'dbuser' host: 'dbhost' (Got timeout reading communication packets)"

    Anybody know why this happens? Is it a mysql problem? a jdbc problem? Is my jboss.jcml incorrecly configured?
    I really have no clue, and would greatly appreciate _any_ pointers.


    /Jonas Eklöf

    Threaded Messages (4)

  2. JBoss + MySQL problem[ Go to top ]

    My guess is your connections are timing out. MySQL closes connections after a period of non-use (usually 8 hours). I would enable your idle timeout, and set it to something less around 5-10 minutes. If you haven't used a connection in that long, no sense in tying up server resources.
  3. JBoss + MySQL problem[ Go to top ]

    Thanks for the pointers.
    Am I correct in assuming that the container responsible for these connections (JBoss) should "revive" them as they are needed? If things work as they should, of course.


    /Jonas Eklöf
  4. JBoss + MySQL problem[ Go to top ]

    Do you close your connection in the ejbPassivate() and open it again in the ejbActivate() methods? This could be the reason for the timing out of your connection. I assume that you use Bean Managed Persistence, otherwise it won't make sense.

    Sergei Batiuk.
  5. JBoss + MySQL problem[ Go to top ]

    Well, actually I don't use EJB (with MySQL as datasource at least). This datasource that I am having problems with is only used from Servlets and jsp (through "ordinary" javabeans). What I do is that I open and close the connections here. Is this method wrong?