Solve the problem caused by: java.sql.SQLRecoverableException : IO error: connection reset related problems

Solution under Caused by: Java. SQL. SQLRecoverableException: IO Error: Connection reset related issues

Tag: Database connection pool

In the 2014-01-21 s but
18615 people read
Comments (0)
collection
To report


Classification:
 

Copyright Notice: This article is the original article of the blogger, and shall not be reproduced without the permission of the blogger.

Java.SQL.SQLException: Io Exception: Connection reset

When the Connection is created in the database Connection pool and long time not to use cases, the Connection will automatically recycling and failure, but the client does not know, still use for database operations is an invalid database Connection, in this way, will lead to the client program to “Java. SQL. SQLException: Io exception: Connection reset” or “Java. SQL. SQLException closed Connection”.
Add after configuring the data source
< property name=”validationQuery” value=”select * from dual”/>
After the
configuration, the client tests an invalid connection before using it, and if it finds that the connection is invalid, it retrieves a valid database connection from the connection pool for use.

 
When setting the data source in Tomcat’s context.xml, please refer to:
& lt; Resource auth=”Container”
driverClassName=” OracleDriver”
type=”javax.sql.DataSource”
url=” JDBC :oracle:thin:@11.11.11.45:1521:orcl”
name=” JDBC /login”
The username = “login”
the password = “login”
maxActive = “15”
maxIdle = “10”
maxWait = “1”
minIdle = “2”, “
removeAbandonedTimeout =” 5 “
testOnBorrow =” true “
TestWhileIdle =”true”
testOnReturn=” br> “
removeAbandoned=”true”
logAbandoned=”true”
validationQuery=”select 1 from dual”
/>

& lt; Resource auth=”Container”
driverClassName=” OracleDriver”
type=”javax.sql.DataSource”
url=” JDBC :oracle:thin:@11.11.11.44:1521:orcl”
name=” JDBC /intraweb”
The username = “intraweb”
the password = “intraweb”
maxActive = “15”
maxIdle = “10”
maxWait = “1”
minIdle = “2”, “
removeAbandonedTimeout =” 5 “
testOnBorrow =” true “
TestWhileIdle =”true”
testOnReturn=” br> “
removeAbandoned=”true”
logAbandoned=”true”
validationQuery=”select 1 from dual”
/>

————————————————————-
The above is an article from the Internet. There are several possible reasons for Connection Reset:
1. The number of connections in the configured data connection pool is insufficient;
2. The connection in the database connection pool is not used for a long time, the database actively disconnects, and the client does not know that it still gets an invalid connection when it is in use;
Corresponding to the causes of the above two conjectures, the following are processed:
1. Configure the maximum, minimum and free connections of the connection pool, etc.;
2. Configure the connection in the connection pool to check the validity of the connection, for example, configure the validity of the connection to check the SQL statement, whether the configuration to check the validity of the connection;

The above is just an idea. The specific configuration content should be configured according to different data sources, and the solution can be referred to above. As for whether there are other reasons, it is unknown for now.
In my project, I used c3P0 data source. At that time, I added configuration related to validity check according to the configuration mode of C3P0. For detailed configuration of C3P0, please refer to:
http://blog.csdn.net/majian_1987/article/details/18598857

Read More: