Hi all I knew it is a old question but just curious today. As we know connection.close will also close preparedStatement(correct me if I am wrong). but what if I close connection then close preparedStatement
conn.close();
ps.close();
Will I get a nullpointer exception?
Someone was saying depends on your jvm speed.sometimes ps.close() will run ahead and close first before conn.close finish his job and so you wont get nullpointer.
In order to test that, I have modified the code
conn.close();
Thread.sleep(5000);//I give 5s to conn.close to finish his work. should be enough
ps.close();
But I didn't get the nullpointer.
So my question is what happened here if i close conn first and then ps.
thanks all.
PreparedStatementbefore theConnection(and theResultSetbefore thePreparedStatement). - user207421