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"
/>