[Solution] dbcp (Oracle) reconnection problem Cause: java.sql.SQLException: No more data to read from socket

Problem with dbcp (Oracle) relink - Cause: java.sql.SQLException: No more data to read from socket

1. Problem

In business development, dbcp is used as a connection pool. After an oracle database restart, an error has been reported. This Cause: java.sql.SQLException: No more data to read from socket always appears (mybatis+spring).

Normal after restarting the service.

2. Reason

This exception is usually due to the use of a connection pool. When the connection obtained from the connection pool fails or times out, using this connection for database operations will throw the above exception. 

After investigation, it was found that when using the connection, it was not verified whether it was available.

3. Solve 


The solution is to let the database connection pool check whether the connection has timed out or failed before returning the connection to you. If so, evict the connection and return an available connection. 

The actual operation is to add an attribute in the bean of the connection pool in the configuration file of spring-dao.xml (database related configuration file, the name of each company is not necessarily the same) <property name="validationQuery" value="SELECT 1 FROM DUAL" /> is to check whether the connection is available before using it, and it is not possible to reassign an available one

 

Guess you like

Origin blog.csdn.net/yy4545/article/details/108302771