Java. SQL. sqlexception: Io exception: Connection Reset

Source: Internet
Author: User

When a connection in the database connection pool is created and is not used for a long time, the connection is automatically reclaimed and becomes invalid, but the client does not know, during database operations, the client still uses an invalid database connection.Program"Java. SQL. sqlexception: Io exception: Connection Reset" or "Connection closed by Java. SQL. sqlexception" is reported.

Add

<Property name = "validationquery" value = "select * from dual"/>

After configuration, the client will test the connection when using an invalid connection. If the connection is found to be invalid, it will obtain a valid database connection from the connection pool again for use.

 

When setting the data source in Tomcat context. XML, refer:

<Resource auth = "Container"
Driverclassname = "oracle. JDBC. oracledriver"
Type = "javax. SQL. datasource"
Url = "JDBC: oracle: thin: @ 11.11.11.45: 1521: orcl"
Name = "JDBC/login"
Username = "login"
Password = "login"
Maxactive = "15"
Maxidle = "10"
Maxwait = "-1"
Minidle = "2"
Removeabandonedtimeout = "5"
Testonborrow = "true"
Testwhileidle = "true"
Testonreturn = "true"
Removeabandoned = "true"
Logabandoned = "true"
Validationquery = "select 1 from dual"
/>

<Resource auth = "Container"
Driverclassname = "oracle. JDBC. oracledriver"
Type = "javax. SQL. datasource"
Url = "JDBC: oracle: thin: @ 11.11.11.44: 1521: orcl"
Name = "JDBC/intraweb"
Username = "intraweb"
Password = "intraweb"
Maxactive = "15"
Maxidle = "10"
Maxwait = "-1"
Minidle = "2"
Removeabandonedtimeout = "5"
Testonborrow = "true"
Testwhileidle = "true"
Testonreturn = "true"
Removeabandoned = "true"
Logabandoned = "true"
Validationquery = "select 1 from dual"
/>

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.