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:
- Caused by: java.net.SocketException : connection reset or caused by: java.sql.SQLRecoverableException solve
- java.sql.SQLRecoverableException: IO Error: Connection reset
- Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
- Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no furthe
- Caused by: java.io.IOException: APR error: -730053
- Java connection SQL error, network error IO Exception:Connection refused :connect
- Process of checking the error of connection reset by peer reported by reactor netty
- Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0
- java.sql.SQLException : IO exception: socket read timed out
- Nginx: recv() failed (104: connection reset by peer) troubleshooting
- Several problems caused by device encryption
- About connection reset by peer: socket write error
- ConnectionResetError: [Errno 104] Connection reset by peer
- GPU hardware acceleration related problems, solve flash screen
- subsystem request failed on channel 0 Couldn’t read packet: Connection reset by peer
- java.sql.SQLException: The Network Adapter could not establish the connection
- A series of problems caused by the option allow output folders for source folders
- java.sql.SQLException : IO error: socket read timed out!
- android Caused by: java.util.ConcurrentModificationException
- How to solve problems like curl: (7) failed to connect to raw.githubusercontent.com Port 443: problem with connection used