Bug #5069 NullPointerExcept: ResultSetMetaData.getColumnCount(ResultSetMetaData.java:315)
Submitted: 17 Aug 2004 3:38 Modified: 31 Mar 2014 7:27
Reporter: Ken Johanson Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.1-nightly-20040815 OS:Any
Assigned to: Mark Matthews CPU Architecture:Any

[17 Aug 2004 3:38] Ken Johanson
Description:
Getting a NullPointerException at com.mysql.jdbc.ResultSetMetaData.getColumnCount(ResultSetMetaData.java:315)

How to repeat:
The code that causes this is roughly:

PreparedStatement ps = con.prepareStatement(query);
//ps.setObject(i+1, args[i]);
ResultSet rs = ps.executeQuery();
ResultSetMetaData md = rs.getMetaData();
colLen = md.getColumnCount();
[17 Aug 2004 4:02] Mark Matthews
Unfortunately your rough code doesn't make this repeatable (just checked, I don't get a null pointer exception with that code).

My guess is you're calling getMetaData() _after_ the result set has been closed? (either explicitly, or implicitly by closing the statement that created it, or executing another query on the same statement?).

I will add a check so that you get the _correct_ exception, but you will now see a 'Result set closed' exception.
[17 Aug 2004 5:07] Ken Johanson
Right you are, it was being closed in a try-finally, on this bug and the last relating to PreparedStatement. My Aplogies, and thank you. Case closed.