JDBC and Insert a new row after the last position
Posted in 2005
Jdbc V 2.21.JC3 engine 9.30 example taken from UpdateCursor1.java: when i read the documentation about resultset.insertRow() it inserts a row in the database table and in the resultset. when i try to fetch all the records in the resultset the last inserted row is not there. the table tab has only one row in it (1,"one",1); code fragment: System.out.println("Use rowid in the query"); pstmt = conn.prepareStatement("select *, rowid from tab ", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = pstmt.executeQuery(); System.out.println("Insert a new row after the last position"); rs.last(); rs.moveToInsertRow(); rs.updateInt(1,999); rs.updateString(2,"z"); rs.updateFloat(3,(float)99.9); rs.insertRow(); rs.moveToCurrentRow(); rs.first(); System.out.println("insertRow() " + rs.getInt(1) +":"+ rs.getString(2) +":"+ rs.getFloat(3) +":"+ // rs.getInt(4) + ":" ); while( rs.next() ){ System.out.println("insertRow() " + rs.getInt(1) +":"+ rs.getString(2) +":"+ rs.getFloat(3) +":"+ rs.getInt(4) + ":" ); after the code above i expect insertRow() 1:1 :1.0: insertRow() 999:z :99.9:285: however i get: insertRow() 1:1 :1.0: what am i missing?? or does it works as it should do. comments are welcome. Thanks Superboer