fatcodeguy
Programmer
How do I set up destructors in Java. When I exit the program, or end a connection, I want it to display that the connection has been closed. I know how to do this in C++, but not in Java. Any help would be great! Thanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
super.close();
System.out.println("Connection closed.");
Connection conn = null;
try {
conn = getConnection(); // get you connection somehow
// Do stuff with conn
}
finally {
if (conn != null) {
try { conn.close(); }
catch (Exception ex) {}
}
}
System.out.println("Connection is closed.");