Dose BoneCP (JDBC pool Library) support auto reconnect in case of DB server restart? If so how to configure it in spring

356 views Asked by At

I’m using BoneCP JDBC connection pool in my spring based application. I wondering whether it automatically reconnect to the DB server in case of DB server restart. I didn’t found any documentation on such support in BoneCP official web site. I found it’s default configuration file “bonecp-default-config.xml “ in Git hub page as mentioned below

<!-- Sets the number of ms to wait before attempting to obtain a connection 
again after a failure. -->
        <property name="acquireRetryDelayInMs">7000</property>

<!-- After attempting to acquire a connection and failing, try to connect these many times before giving up. Default 5. -->
        <property name="acquireRetryAttempts">5</property>

With this configuration it seems to be support auto reconnect, but not user abou the behavior and how to use this properties in spring configuration file.

My spring configuration as below

<bean id="refDBDatasource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
        <property name="driverClass" value="${jdbc.driverClassName}" />
        <property name="jdbcUrl" value="${refdb.jdbc.url}" />
        <property name="username" value="${refdb.jdbc.username}" />
        <property name="password" value="#{T(com.dhl.gcdb.dte.util.SecurityUtil).decriptPWD('${refdb.jdbc.password}')}" />
        <property name="idleConnectionTestPeriodInMinutes" value="#{T(com.dhl.gcdb.dte.util.CommonUtil).convertToInt('${refdb.idle.connection.test.period.in.minutes}')}" />
        <property name="idleMaxAgeInMinutes" value="#{T(com.dhl.gcdb.dte.util.CommonUtil).convertToInt('${refdb.idle.max.age.in.minutes}')}" />
        <property name="maxConnectionsPerPartition" value="#{T(com.dhl.gcdb.dte.util.CommonUtil).convertToInt('${refdb.max.connections.per.partition}')}" />
        <property name="minConnectionsPerPartition" value="#{T(com.dhl.gcdb.dte.util.CommonUtil).convertToInt('${refdb.min.connections.per.partition}')}" />
        <property name="partitionCount" value="#{T(com.dhl.gcdb.dte.util.CommonUtil).convertToInt('${refdb.partition.count}')}" />
        <property name="acquireIncrement" value="#{T(com.dhl.gcdb.dte.util.CommonUtil).convertToInt('${refdb.acquire.increment}')}" />
        <property name="statementsCacheSize" value="#{T(com.dhl.gcdb.dte.util.CommonUtil).convertToInt('${refdb.statements.cache.size}')}" />

    </bean>

Here my more specific questions are

  1. Will it support auto reconnect or not
  2. If supports how to set that properties in spring
  3. If supports, how it behave

    3.1. Will it retry up to acquireRetryAttempts times, with a delay of acquireRetryDelayInMs between each attempt?

    3.2. How it behaves once a full round of acquisition attempts fails? will it remain active, and will try again to acquire Connections in response to future requests for Connections?

Thanks in advance.

0

There are 0 answers