/** * */ package testsuite.simple; import java.sql.ResultSet; import java.sql.SQLException; import javax.sql.rowset.CachedRowSet; import com.sun.rowset.CachedRowSetImpl; import testsuite.BaseTestCase; /** * @author Tonci * */ public class TestBug45757 extends BaseTestCase { /** * @param name */ public TestBug45757(String name) { super(name); // TODO Auto-generated constructor stub } public void testBug45757() throws Exception { try { System.out.println("java.vm.version : " + System.getProperty("java.vm.version")); System.out.println("java.vm.vendor : " + System.getProperty("java.vm.vendor")); System.out.println("java.runtime.version : " + System.getProperty("java.runtime.version")); System.out.println("os : " + System.getProperty("os.name") + ", " + System.getProperty("os.version") + ", " + System.getProperty("os.arch")); System.out.println("sun.management.compiler : " + System.getProperty("sun.management.compiler")); System.out.println("-------------------------------------------------"); try { this.conn.setAutoCommit(false); createTable("bug45757", "(id INTEGER NOT NULL PRIMARY KEY)"); //this.stmt.executeUpdate("Insert into bug45757 (id) values (1)"); this.pstmt = this.conn.prepareStatement("SELECT id FROM bug45757 WHERE id=2 FOR UPDATE", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); this.rs = this.pstmt.executeQuery(); assertFalse(this.rs.next()); this.rs.moveToInsertRow(); this.rs.updateInt("id", 1); try { this.rs.updateRow(); System.err.println("FAIL: ResultSet.updateRow fails to throw SQLException when cursor is on insert row"); } catch(SQLException sqle) { // Expected System.err.println("PASS: ResultSet.updateRow throws SQLException when cursor is on insert row"); } this.rs.close(); this.pstmt.close(); this.conn.commit(); this.conn.close(); } finally { closeMemberJDBCResources(); } } finally { closeMemberJDBCResources(); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub junit.textui.TestRunner.run(TestBug45757.class); } }