I`m using the following method to close my connection to 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;
}
}
My first System.out.println
doesn`t print anything which means try is not performed, and I get above indicated exception.
As I know "A successful shutdown always results in an SQLException" but does it mean the try statement is not performed? Thanks for your help.