Friday 17 February 2012

How to automatically reconnect a Data source when the Application server and DBMS are not on the same server?

When I have started working on my current project (a J2EE software that will manage all travel agencies of Cameroon), I faced a problem I didn't heard about before. In fact, before digging into the problem allow me to brieftly describe the architecture of the system.
In fact we are using a J2EE architecture (using JBoss as application server) with rich clients (Swing), and our data are stored in Oracle 10g. But the very concern here is that JBoss and Oracle are located on two different servers bounds by a network connection. Therefore, what could be the problem?
When I was doing tests, due to my environment, sometimes the network connection was lost, and once it was restablished, my datasource could no longer connect to Oracle, I then needed to restart this datasource. This problem could be worst in an exploitation environment, since the service could be stopped longer than accepted.
Overcome this problem, could be done by a good configuration of the datasource, by adding a tag <valid-connection-checker-class-name>, and in my case that's the tag I've added:
<valid-connection-checker-class-name>  
org.jboss.resource.adapter.jdbc.vendor. OracleValidConnectionChecker 
<\valid-connection-checker-class-name>

I hope this post will help you to overcome quickly this kind of problem, and even if this connection will be lost rarely, it's better to anticipate.

No comments:

Post a Comment