i4late / log4jdbc-remix

Automatically exported from code.google.com/p/log4jdbc-remix
0 stars 0 forks source link

ResultSetSpy#next causes NullPointerException #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
java.lang.NullPointerException
     at net.sf.log4jdbc.DefaultResultSetCollector.setupColNameToColIndexMap(DefaultResultSetCollector.java:84)
     at net.sf.log4jdbc.DefaultResultSetCollector.getMetaDataIfNeeded(DefaultResultSetCollector.java:76)
     at net.sf.log4jdbc.DefaultResultSetCollector.methodReturned(DefaultResultSetCollector.java:127)
     at net.sf.log4jdbc.ResultSetSpy.reportAllReturns(ResultSetSpy.java:89)
     at net.sf.log4jdbc.ResultSetSpy.reportReturn(ResultSetSpy.java:159)
     at net.sf.log4jdbc.ResultSetSpy.next(ResultSetSpy.java:1998)

Connection conn = ...;
String sql = ...;
PreparedStatement stmt = conn.prepareStatement(sql, 
PreparedStatement.RETURN_GENERATED_KEYS);
// ...
stmt.executeBatch();
ResultSet rs = stmt.getGeneratedKeys();
rs.next();

Original issue reported on code.google.com by dai.0...@gmail.com on 26 Jan 2012 at 6:17

GoogleCodeExporter commented 9 years ago
I can't reproduce this in a test, but I think its because I am using H2 which 
gives the column name of a generated key column as "SCOPE_IDENTITY()". But I'm 
guessing that some jdbc drivers return a null column name for identity columns 
so I have added a != null check in the code.

Original comment by tim.azzo...@gmail.com on 27 Jan 2012 at 12:35

GoogleCodeExporter commented 9 years ago
Please can you let me know if 0.2.7 fixes the problem for you?

Original comment by tim.azzo...@gmail.com on 27 Jan 2012 at 12:45

GoogleCodeExporter commented 9 years ago
I'm sorry.  My description of environment is too short.
I use MySQL v5.5.12 and mysql-connector-java v5.1.18.

When I examined the flow, I expected that ResultSetMetaData.getColumnName(1) 
returns "GENERATED_KEY", but it returns null.  In compensation, 
getColumnLabel(1) returns "GENERATED_KEY".
Next, I expected that this always returns null, but it occurs on the specific 
condition.  Finally, I cannot find the condition.

I thank you for your prompt action.  I will you know if this bug is fixed.  
When will you release 0.2.7?

Original comment by dai.0...@gmail.com on 27 Jan 2012 at 1:32

GoogleCodeExporter commented 9 years ago
Its released now. Thanks.

Original comment by tim.azzo...@gmail.com on 27 Jan 2012 at 8:35

GoogleCodeExporter commented 9 years ago
I confirmed that this bug is fixed.
Thank you!

Original comment by dai.0...@gmail.com on 28 Jan 2012 at 12:45

GoogleCodeExporter commented 9 years ago

Original comment by tim.azzo...@gmail.com on 28 Jan 2012 at 10:27