Problems with the Tomcat JDBC Connection pool not being re-connected

Source: Internet
Author: User

Using Tomcat's JDBC Connection pool in the project, the problem was that when the database was restarted, the service did not reconnect to the database and needed to restart the deployed project to connect to the database. After testing the configuration to make a change:

Add two configuration attributes where DataSource is configured:

        <name= "Testonborrow"  value= "true"/>          <!-- An SQL statement used to verify that a connection is valid before it is returned to the caller, and if an SQL statement is specified, it must be a SELECT statement with at least one row of results         -- <  name= "Validationquery"  value= "Select 1"/>

Such as:

 <BeanID= "DataSource"class= "Org.apache.tomcat.jdbc.pool.DataSource"Destroy-method= "Close">        <!--Connection Info -       < Propertyname= "Driverclassname"value= "${jdbc.driver}" />        < Propertyname= "url"value= "${jdbc.url}" />        < Propertyname= "username"value= "${jdbc.username}" />        < Propertyname= "Password"value= "${jdbc.password}" />        < Propertyname= "Maxactive"value= "${jdbc.pool.maxactive}" />        < Propertyname= "Maxidle"value= "${jdbc.pool.maxidle}" />        < Propertyname= "Minidle"value= "0" />        < Propertyname= "Defaultautocommit"value= "false" />        <!--timeout after connecting Idle10 minutes, check every 1 minutes -        < Propertyname= "Timebetweenevictionrunsmillis"value= "60000" />        < Propertyname= "Minevictableidletimemillis"value= "600000" />        < Propertyname= "Testonborrow"value= "true"/>         <!--an SQL statement used to verify that a connection is valid before it is returned to the caller, and if an SQL statement is specified, it must be a SELECT statement with at least one row of results -        < Propertyname= "Validationquery"value= "Select 1"/>     </Bean>

Problems with the Tomcat JDBC Connection pool not being re-connected

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.