Bug #1630 ResultSet.updateXXX() -> driver crash if resultset is not updatable
Description:
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?
Teemu
How to repeat:
Table definition:
----------------------------------------
CREATE TABLE `test1` (
`b` varchar(5) NOT NULL default '',
`a` int(11) default NULL
) TYPE=MyISAM
----------------------------------------
Example code:
----------------------------------------
ResultSet rs = null;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
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.absolute(1);
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();}
try
{
rs.updateInt(2, 1); // Second updateXXX call produce NullPointerException
}
catch (SQLException e) {e.printStackTrace();}
---------------------------------------
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: 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? Teemu How to repeat: Table definition: ---------------------------------------- CREATE TABLE `test1` ( `b` varchar(5) NOT NULL default '', `a` int(11) default NULL ) TYPE=MyISAM ---------------------------------------- Example code: ---------------------------------------- ResultSet rs = null; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); 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.absolute(1); 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();} try { rs.updateInt(2, 1); // Second updateXXX call produce NullPointerException } catch (SQLException e) {e.printStackTrace();} ---------------------------------------