I m using a web application and, sometimes, I have MySql connection problems.
Using the testConnectionOnCheckout
and preferredTestQuery
options in the Hibernate configuration file, I resolved the problem and my application is ok now.
但是,为了提高业绩,我只想在我提出申请时获得这一选择的效果。 例如:
try {
...........
}
catch(Exception e) {
// java code to obtain the same effect as
// testConnectionOnCheckout option with "Select 1" query
}
我必须使用哪些 Java法?