Hi everyone, I knew this was an old question, but just curious today. As you know, connection.close will also close the prepared statement (correct me if I am wrong). but what if I close the connection then close the prepared statement
conn.close();
ps.close();
Will I get a nullpointer exception?
Someone said depends on your jvm speed. Sometimes ps.close () starts ahead and closes first before conn.close finishes its work and therefore you will not get nullpointer.
To check this, I changed the code
conn.close();
Thread.sleep(5000);
ps.close();
But I did not get a null pointer.
So my question is what happened here if I close conn first and then ps.
thank you all.
source
share