A piece of advice: use a debugger, given that we have no way of reproducing the scenario and the code posted so far looks OK.
BTW, why are you catching a
NullPointerException ? Catching unchecked exceptions without any kind of processing is *always* a bad practice and screams of a pre-condition check. Instead put null checks before closing the database resources [like result sets and statements].
Connection conn = null;
Statement stmt = null;
try {
try {
// do something
} finally {
if(stmt != null) stmt.close();
if(conn != null) conn.close();
}
} catch(Exception e) {
e.printStackTrace();
}
I don't accept change; I don't deserve to live.