I am getting a little confused. I was reading the below from Java Database Connectivity:
Connection conn = DriverManager.getConnection(
"jdbc:somejdbcvendor:other data needed by some jdbc vendor",
"myLogin",
"myPassword" );
Statement stmt = conn.createStatement();
try {
stmt.executeUpdate( "INSERT INTO MyTable( name ) VALUES ( 'my name' ) " );
} finally {
// It's important to close the statement when you are done with it
stmt.close();
}
Do you not need to close the conn
connection?
What is really happening if the conn.close() doesn't occur?
I have a private web application I'm maintaining that doesn't currently close either form, but is the important one really the stmt
one, the conn
one, or both?
The site keeps going down intermittently, but the server keeps saying it's a database connection issue. My suspicion is that it's not being closed, but I don't know which, if any, to close.