Bug #1630 ResultSet.updateXXX() -> driver crash if resultset is not updatable
Submitted: 22 Oct 2003 11:53 Modified: 31 Oct 2003 20:52
Reporter: Teemu Kuulasmaa Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S2 (Serious)
Version:3.0.9-stable OS:Any (all)
Assigned to: Mark Matthews CPU Architecture:Any

[22 Oct 2003 11:53] Teemu Kuulasmaa
I have a table without a primary key. If I try to create a updatable resultset and select all columns from the table, JDBC driver is not able to update the table. This is understandable and totally OK! But if I still try to update the resultset using ResultSet.updateXXX() method I'll first get SQLException and all subsequent ResultSet.updateXXX() method calls produce NullPointerException. Why is that? Shouldn't ResultSet.updateXXX() methods always produce only SQLExceptions if resultset is not updatable?


How to repeat:
Table definition:
CREATE TABLE `test1` (
  `b` varchar(5) NOT NULL default '',
  `a` int(11) default NULL

Example code:
ResultSet rs = null;
  Connection conn =     DriverManager.getConnection("jdbc:mysql://localhost:3306/test/?user=xxx&password=xxx");
  Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
  rs = stmt.executeQuery("select * from test1");
  rs.updateInt(2,1); // The first updateXXX call produce SQLException
catch (SQLException e) {e.printStackTrace();}
catch (InstantiationException e) {e.printStackTrace();} 
catch (IllegalAccessException e) {e.printStackTrace();} 
catch (ClassNotFoundException e) {e.printStackTrace();}		

  rs.updateInt(2, 1);  // Second updateXXX call produce NullPointerException
catch (SQLException e) {e.printStackTrace();}

[31 Oct 2003 20:52] Mark Matthews
Thank you for your bug report. This issue is fixed in the source tree for Connector/J 3.0 and 3.1 branches. See http://downloads.mysql.com/snapshots.php for a nightly snapshot to test with.