Bug #718 NullPointerException in extractDefaultValues of UpdatableResultSet
Submitted: 25 Jun 2003 6:54 Modified: 26 Jun 2003 7:35
Reporter: David Marquis Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.1 OS:Windows (Win2k)
Assigned to: CPU Architecture:Any

[25 Jun 2003 6:54] David Marquis
Description:
A call to (Updatable)ResultSet.moveToInsertRow() throws a NullPointer exception :

java.lang.NullPointerException
	at com.mysql.jdbc.UpdatableResultSet.extractDefaultValues(UpdatableResultSet.java:2122)
	at com.mysql.jdbc.UpdatableResultSet.moveToInsertRow(UpdatableResultSet.java:512)

How to repeat:
Simply call (Updatable)ResultSet.moveToInsertRow()
[25 Jun 2003 7:02] David Marquis
It seems that ResultSet.tableName is never set.
[25 Jun 2003 7:10] David Marquis
Suggested fix:

Adding these lines 

if(fields != null && fields.length > 0)
    tableName = fields[0].getTableName();

in both constructors of UpdatableResultSet fixed the problem. This takes into consideration that the UpdatableResultSet always contains fields from 1 table only. 
If the driver supports multi-table updates one day, this will have to be changed, i guess.
[25 Jun 2003 7:11] Mark Matthews
What version of the server are you using?
[25 Jun 2003 7:36] David Marquis
MySQL version is 4.0.13-max-nt (latest I think)
[26 Jun 2003 7:35] Mark Matthews
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html

This is now fixed. Thank you for your bug report.