Mega Code Archive

 
Categories / Java Tutorial / Database
 

Test to See if Your Connection is Alive

For Oracle database: you may use the Connection object with query of "select 1 from dual"; if the query returns the result, then it is a valid Connection object. For MySQL database: you may use the Connection object with query of "select 1"; if the query returns the result, then it is a valid Connection object.