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
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.
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.
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?
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:
<check-valid-connection-sql>SELECT 1 FROM sysobject</check-valid-connection-sql>
I am newbie to JBoos but need to make this work. Thank you all for any help.