GenericJDBCException with message "could not prepare statement" on JWS Tomcat with Hybernate
Issue
-
We have configured Tomcat with a datasource including validation and abandon checks:
<Resource name="jdbc/myDB" ... testwhileIdle="true" testOnBorrow="true" validationQuery="SELECT 1 FROM DUAL" validationInterval="30000" ... removeAbandonedTimeout="300" removeAbandoned="true" logAbandoned="true" ... />
When we have network issues it seems like the pool is not managing the validation or abandoned connections properly because after some time requests start failing with these traces:
Caused by: java.sql.SQLException: Connection has already been closed. at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:117) ~[tomcat-jdbc.jar:?] at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108) ~[tomcat-jdbc.jar:?] ...
Environment
- Red Hat JBoss Web Server (JWS)
- Red Hat build of Quarkus
- Hybernate ORM
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.