SQLCODE and stale connection detection and handling
We would like to detect stale connection and handle it.
We can handle the stale connection either at the time when we get the DB connection from connection pool, or when the connection is actually used.
To handle stale connection at the time when we get the connection requires issuing DB operations to see if the connection is valid. This seems expensive.
So I personally think it is better to handle the stale connection when connection is actually used and SQLException is thrown.
However, I haven't figured out or found information on the following issues. Hope anyone in this forum can help out with your knowledge and ideas.
Regarding Stale connection detection
1. Is it possible to detect stale connection from SQLException? Is it through SQLCODE/SQLSTATE?
2. Where to find the list of SQLCODE? Will it be db vendor specific?
Regarding stale connection handling
1. Usually how to handle the stale connection from connection pool (if it is being detected)? If the connection is just closed, will connection pool purge the connection? How to make sure the stale connection is purged from connection pool?
Any thought or reference on stale connection detection and handling is appreciated.
Thanks a lot.