Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#18 NPE on closing result set

open
nobody
JDBC Driver (3)
5
2008-06-19
2008-06-19
Tracy Hartley
No

I have a problem with null pointer exceptions on closing resultsets.

I have identified three situations where this occurs:

1. If the related statement is closed first, ie
st.close();
rs.close();

instead of
rs.close();
st.close();

2. If the same statement that returned the result set is then reused in a way that doesn't return a resultset, e.g.
rs = st.executeQuery("some sql ...");
st.executeUpdate("some other sql ...");
rs.close();

Moving the rs.close() to before the second use of the statement gets rid of the NPE.

3. If the sql query causes an sql exception to be thrown. In this case we get a null pointer exception and never get to see the stack trace from the SQLException.

I am using version 1.0.24 beta.

Discussion