6 Replies Latest reply: May 24, 2013 1:20 PM by Alek M RSS

JBoss does not reconnect after mysql-server restart

ws ws Newbie

Hello,

I am using JBoss 4.2.2, mysql-connector-java-5.1.5 and mysql-server 5.1.

I sometimes have to restart my mysql-server (/etc/init.d/mysql restart). However, when I do this, JBoss does not reconnect. I get com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure.

My question: How can I configure JBoss to automatically reconnect when I manually restart my mysql-server?

Here is my mysql-ds.xml configuration:

<local-tx-datasource>
 <jndi-name>meetings</jndi-name>
 <connection-url>jdbc:mysql://localhost:3306/meetings</connection-url>
 <driver-class>com.mysql.jdbc.Driver</driver-class>
 <user-name>userame</user-name>
 <password>password</password>
 <valid-connection-checker-classname>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-classname>
 <metadata>
 <type-mapping>mySQL</type-mapping>
 </metadata>
</local-tx-datasource>


I have also tried to use the reconnect property in mysql-ds.xml, however with no success
<connection-property name="autoReconnect">true</connection-property>
Besides, In the documentation I have read not to use this.

Please help. I need the database-connection to be reconnected after the mysql-server restart.
Regards,
Walter


  • 1. Re: JBoss does not reconnect after mysql-server restart
    Peter Johnson Master

    Try "touching" the *-ds.xml file. That will update the last modified timestamp which will cause the app server to redeploy the datasource.

  • 2. Re: JBoss does not reconnect after mysql-server restart
    henk de boer Master

     

    "PeterJ" wrote:
    Try "touching" the *-ds.xml file. That will update the last modified timestamp which will cause the app server to redeploy the datasource.


    Peter, is there any more automatic recovery available? I just encountered a similar problem. We have many Jboss AS instances connecting to a central DB. Because of a full disk the DB (Postgres) stopped working and after resolving the problem the DB had to be restarted.

    The problem was that none of the Jboss instances were able to connect anymore after this restart and they all had to be restarted manually. This is rather tedious to say the least. Touching the *-ds.xml file reliefs this pain only a little.

  • 3. Re: JBoss does not reconnect after mysql-server restart
    henk de boer Master

    I found this other thread: http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4158716

    It seems that if you have valid connection checker, then basically the redeployment of the datasource would not really be needed. Sure, it might still be better to redeploy instead of waiting for every connection to have thrown an exception, but eventually the pool *should* recover automatically. Only. clearly it doesn't (or it doesn't always). The topic starter has a valid connection checker configured, so if I understand correctly those connections should have been closed and re-opened, shouldn't they?

  • 4. Re: JBoss does not reconnect after mysql-server restart
    henk de boer Master

    Anyone any ideas?

  • 5. Re: JBoss does not reconnect after mysql-server restart
    rajesh gupta Newbie

    Hi

    I am using Jboss5.1.0 and i configured the same *-ds.xml file as mentioned above with mysql as
    DB. After restart of DB, jboss is able to connect to DB. Everything worked for me.

     

    Thanks,

    Rajesh N

  • 6. Re: JBoss does not reconnect after mysql-server restart
    Alek M Newbie

    Hello. Would you mind to  show  configuration of your *-ds. xml file? I have configured my datasource file with suggested steps but  Jboss doesnot reconnect  when mysql database restart. Here is content of my -ds.xml file:

    <datasources>
            <local-tx-datasource>

                   <local-tx-datasource>
                    <jndi-name>MSSQLMWCONFIGDS</jndi-name>
                    <connection-url>jdbc:sqlserver://servername\ddb2:55428;databaseName=databasename;</connection-url>
                    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
                    <user-name>user_u</user-name>
                    <password>user_u</password>
                    <autoReconnect>true</autoReconnect>
                    <check-valid-connection-sql>SELECT 1 FROM sysobject</check-valid-connection-sql>
                    <failOverReadOnly>false</failOverReadOnly>
                    <maxReconnects>50</maxReconnects>
                    <initialTimeout>15</initialTimeout>
                    <metadata>
                    <type-mapping>MS SQLSERVER2000</type-mapping>
                    </metadata>
    </local-tx-datasource>

    </datasources>

     

    I am newbie to JBoos but need to make this work. Thank you all for any help.