0 Replies Latest reply on Apr 10, 2015 9:12 AM by Poornima Abhilash

    Mysql connection to idm/jcr lost after a period of inactivity

    Poornima Abhilash Newbie

      Hi All,

       

      I have a web application deployed in GateIn3.6 with JBoss AS 7. We have connected to GateIn's idm/jcr databases via Mysql.But now, we face a issue.Its connection is lost when the application is inactive for a period of time, say some 8 hrs.Usually it happens when we login to the application in the morning after being inactive througout the night.What could be the issue?Read in many forums that mysql usually will disconnect when idle for a long time.How can we remove the idle connections and open a new connection?

       

      Following are the configurations made :

      1)Standalone.xml

       

                     <datasource jndi-name="java:/jdbcidm_test" pool-name="IDMTestPortalDS" enabled="true" use-java-context="true">

                          <connection-url>jdbc:mysql://192.168.10.25:3306/bmit</connection-url>

                          <driver>mysql</driver>

                          <security>

                              <user-name>bmit</user-name>

                              <password>bmit12$</password>

                          </security>

                      </datasource>

                      <datasource jndi-name="java:/jdbcjcr_test" pool-name="JCRTestPortalDS" enabled="true" use-java-context="true">

                          <connection-url>jdbc:mysql://192.168.10.25:3306/bmit</connection-url>

                          <driver>mysql</driver>

                          <security>

                              <user-name>bmit</user-name>

                              <password>bmit12$</password>

                          </security>

                      </datasource>

                      <drivers>

                          <driver name="mysql" module="com.mysql">

                              <driver-class>com.mysql.jdbc.Driver</driver-class>

                              <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>

                          </driver>

                          <driver name="h2" module="com.h2database.h2">

                              <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>

                          </driver>

                      </drivers>

      2) modules.xml(

       

      <?xml version="1.0" encoding="UTF-8"?>

       

      <module xmlns="urn:jboss:module:1.0" name="com.mysql">

        <resources>

          <resource-root path="mysql-connector-java-5.1.32-bin.jar"/>

        </resources>

        <dependencies>

          <module name="javax.api"/>

          <module name="javax.transaction.api"/>

        </dependencies>

      </module>

       

      Read that the parameters , testWhileIdle="true" timeBetweenEvictionRunsMillis="30000" validationQuery="SELECT 1" can be given.But in which file we shall provide these?

      Our application is using apache DBCP which is configured using Spring.

       

      Pls help..