简体   繁体   中英

Application hangs while getting a connection from a “stale connection pool”

I have written a java app which first creates a connection pool at startup and during each refresh, get a connection from the pool, use it, and then close it.The problem happens when I get disconnected from the network and the user presses the Refresh button. The application seems to go into a hung state (from my debug messages, it shows that it is waiting to get a connection from the pool, which it never gets). Is there anyway, I could timeout this request? I am new to java programming. Any help is appreciated.

Thank you!

You could look at your ConnectionPoolDataSource implementation; it might have a way to reset the pool. I don't know a direct way to know if the network gets disconnected, but you do the reset in a WindowAdapter and just add a reset button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM