Friday 6 December 2013

Setting JBoss 7 to auto reconnect after DB connection fail

Internet connection problems while developing an application which uses a remote database can be a nightmare. Luckly you can configure your JBoss server to auto reconnect to your DB!

Since a few days I'm constantly facing the problem mentioned above. I have a rather poor internet connection and because of that I get disconnected from my remote DB frequently which in turn means that I have to restart the whole JBoss server to restore the connection. Fortunately I've found a very simple solution to this problem. You just need to add the following configuration inside your <datasource>...</datasource> tag in standalone.xml:

   select 1

That's it! Now every time you loose your DB connection it will be restored automatically (a new session will be created). You will still see some connection errors in your server logs, but application will work flawlessly.

No comments:

Post a Comment