3 Replies Latest reply on Nov 25, 2004 3:59 AM by Xenofon Grigoriadis

    JDBC auto-reconnect?

    newadmin Newbie

      I am running JBoss 3.2.5 and oracle 9.2.0.4.0 on solaris 8. If the database crashes, I have to bounce the apps to get them to reconnect to the database. How can I configure JBoss so that it will auto-reconnect to the database after the database comes back up? Any suggestions are welcome.

      Thanks

        • 1. Re: JDBC auto-reconnect?
          Steve Dodge Newbie

          The best way I know to do it is to use a JNDI datasouce configured with a datasource file *-ds.xml in your deploy directory. I use the datasource descriptor below on JBoss 3.2.5 winXP & linux, and it recovers from network outages without having to restart the server. If your applicatioins are not using a JNDI enabled datasource, they probably obtain JDBC connections manually or through stand-alone connection pool. That would explain the need to re-deploy the apps individually. I suggest converting them to use a JNDI datasource, where you have many configurable options for ensuring auto-reconnect. The auto-reconnect options include setting a <check-valid-connection-sql> which will validate a connection everytime it is retrieved from the pool or using a <valid-connection-checker-class-name>. All these options can be found on starting on page 383 of the purchased AdminDevel guide.


          <datasources>
           <local-tx-datasource>
           <jndi-name>OracleDS</jndi-name>
           <connection-url>jdbc:oracle:thin:@10.215.xxx.xxx:1521:XXXXX</connection-url>
           <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
           <user-name>user</user-name>
           <password>pass</password>
           <min-pool-size>2</min-pool-size>
           <max-pool-size>5</max-pool-size>
           <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
           </local-tx-datasource>
          </datasources>
          


          note: the min and max pool size is very small for testing purposes

          Hope this helps

          • 2. Re: JDBC auto-reconnect?
            Elias Ross Master


            The ExceptionSorter is supposed to figure out if your connection has gone bad or not. Can you test on 3.2.6 and give the SQLException message and its error code to me?

            • 3. Re: JDBC auto-reconnect?
              Xenofon Grigoriadis Newbie

               

              "mtb2ride" wrote:
              The best way I know to do it is to use a JNDI datasouce configured with a datasource file *-ds.xml in your deploy directory. ... The auto-reconnect options include setting a <check-valid-connection-sql> which will validate a connection everytime it is retrieved from the pool or using a <valid-connection-checker-class-name>.

              Thanks a lot,

              this also was my problem. But another point is, our client currently uses JBoss 3.0.8. Does he have to upgrade to use this feature? Or is this feature found in version 3.0.8 in another config-file?