Enabling auto reconnect in mysql hibernate spring

Reading Time: 1 minute

in your spring config file append the url entry with the below sample

 

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
          destroy-method="close">
        <property name="driverClassName" value="${database.driverClassName}" />
        <property name="url" value="${database.url}?characterEncoding=UTF-8&amp;autoReconnect=true"/>
        <property name="username" value="${database.user}" />
        <property name="password" value="${database.password}" />
    </bean>

Leave a Reply

Your email address will not be published. Required fields are marked *