views:

185

answers:

1

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: 

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.

Freiheit