문제

I have database handle in channelMap (for 1 connection for all messages) and I reuse the connection for all messages. Now, before performing inserts (to a MySQL database), I want to test if the connection still exists. How do I perform this test?

도움이 되었습니까?

해결책

A crude way is to grab the connection and run a simple query (a simple SELECT or SHOW query would do) and catch the exception.

I think this is all based on JTDS, so you should be able to use Connection.closed which will return true if the connection is closed and false if it is open.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top