Bug #20479 ClassCastException moveToInsertRow(UpdatableResultSet.java:909)
Submitted: 15 Jun 2006 12:22 Modified: 26 Jul 2006 18:17
Reporter: Rudolf Häckel Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:java-5.0-nightly-2006061 OS:Windows (Windows NT)
Assigned to: CPU Architecture:Any

[15 Jun 2006 12:22] Rudolf Häckel
Description:
If a PreparedStaement is used to get a ResultSet
next() and moveToInsertRow() do not work as expected!

How to repeat:
PreparedStatement
pst = con.prepareStatement("SELECT * FROM someTable Where PRIM_KEY > ?", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
pst.setInt(1,1);
//Must get at least one Row to get the Exception
rs = pst.executeQuery();
rs.next();
rs.moveToInsertRow();

//This works fine
Statement st =  con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = st.executeQuery("SELECT * FROM someTable Where PRIM_KEY = 1");
rs.next();
rs.moveToInsertRow();

set session sql_mode = NO_AUTO_VALUE_ON_ZERO
CREATE TABLE someTable(
  PRIM_KEY INTEGER AUTO_INCREMENT NOT NULL ,
......
  CONSTRAINT tbl_PK PRIMARY KEY ( PRIM_KEY ) 
.......

Suggested fix:
UpdatableResultSet
line 83: private Object[] savedCurrentRow;
line 909: this.savedCurrentRow = this.thisRow;
[15 Jun 2006 19:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/7717