【发布时间】:2012-03-27 05:43:25
【问题描述】:
我正在使用以下方法关闭与 java DB 的连接:
public void shutdownDisconnect() {
if(connectionExists) {
String databaseURL = getDBurl();
dbProperties.put("shutdown", "true");
try {
DriverManager.getConnection(databaseURL, dbProperties);
System.out.println("success");
} catch (SQLException ex) {
//shutdown always results in an SQLException
System.out.println(ex);
//This exeption is:java.sql.SQLNonTransientConnectionException: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'databasename' shutdown.
}
connectionExists = false;
}
}
我的第一个 System.out.println 没有打印任何内容,这意味着没有执行 try,并且我得到了上述异常。
据我所知“成功关闭总是会导致 SQLException”,但这是否意味着未执行 try 语句?感谢您的帮助。
【问题讨论】: