If you use hibernate in jboss, you can configure it in the * -ds.xml file in the deployment directory to execute some query before connecting to the connection pool: For example:
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
If you use your own connection pool, you can write something like this:
Connection getConnectionFromPool() { try { //get connection from pool //execute some simple uery that should always work } catch (SocketException s) { //close broken connection and get a new one } return connection; }
Or maybe there is a mechanism for doing this in sleep mode, but I don't know about that.
EDIT: Ok, after reading your question, I skipped that you are using the sleep connection pool. So ignore my answer and look here: Restore hibernation
ajuc
source share