-
Bug
-
Resolution: Future Project
-
P5
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
C:\Programme\Java\jdk1.6.0\bin>java -version
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP-2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Database can be each ODBC-Database. In my TestCase I used MS-Access.
A DESCRIPTION OF THE PROBLEM :
ResultSet#rowDeleted() always results in : java.lang.ArrayIndexOutOfBoundsException: -1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See TestCase in source code section ...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
true, if row was deleted,
false, if row was not deleted.
ACTUAL -
nothing
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.ArrayIndexOutOfBoundsException: -1
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* JdbcOdbcResultSetTest.java
* JUnit based test
*
* Created on 11. Juni 2006, 02:33
*
* $Id: JdbcOdbcResultSetTest.java 83 2006-08-24 20:56:16Z jdk6_JdbcOdbcBugs_ulf $
*/
package sun.jdbc.odbc;
import junit.framework.*;
import java.sql.*;
/**
*
* @author Ulf Zibis, ###@###.###
*/
public class JdbcOdbcResultSetTest extends TestCase {
private static final String URL = "jdbc:odbc:TestData";
private static final String TABLE = "Test1";
private static final String ID = "id";
private static final String STRING1 = "string1";
private static final String INT1 = "int1";
private static final int STRING1_LEN = 100;
private static final String EMPTY_QUERY = "SELECT * FROM "+TABLE+" WHERE "+ID+"=0";
private static final String ORDERED_QUERY = "SELECT * FROM "+TABLE+" ORDER BY "+ID;
private static final String STRING32CHARS = "Here are only 16 + 16 more chars";
private static final String UPDATED19CHARS = "updated to 19 chars";
private static final String INSERTED8CHARS = "inserted";
private Connection myCon = null;
private Statement myStmt;
private JdbcOdbcResultSet myRs;
public JdbcOdbcResultSetTest(String testName) {
super(testName);
System.out.println("Construct JdbcOdbcResultSetTest("+testName+") !!");
}
protected void finalize() throws Throwable {
super.finalize();
try { if (myCon != null) myCon.close(); }
catch (Throwable t) { t.printStackTrace(); }
}
protected void setUp() throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // Obsolete in JDK 6.0
myCon = DriverManager.getConnection( URL);
Statement stmt = myCon.createStatement();
try {
ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM "+TABLE);
rs.next();
//System.out.println( TABLE+" had "+rs.getInt( 1)+" record(s).");
stmt.executeUpdate("DROP TABLE "+TABLE);
}
catch (SQLException se) {
if (se.getErrorCode() == -1305)
System.out.println( TABLE+" was not existent.");
else throw se;
}
stmt.executeUpdate("CREATE TABLE "+TABLE+"( "+ID+" COUNTER PRIMARY KEY, "
+STRING1+" VARCHAR("+STRING1_LEN+"), "
+INT1+" INT)");
//System.out.println("New empty table "+TABLE+" created !");
stmt.close();
myStmt = myCon.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
}
protected void tearDown() throws Exception {
try { if (myCon != null) myCon.close(); myCon = null;}
catch (Throwable t) { t.printStackTrace(); }
}
public void testInsertRow() throws Exception {
System.out.println("testInsertRow()");
try {
myRs = (JdbcOdbcResultSet)myStmt.executeQuery( EMPTY_QUERY);
myRs.next(); // avoid other bug
myRs.moveToInsertRow();
myRs.updateString( STRING1, STRING32CHARS);
myRs.insertRow();
myRs.last(); // Is this allways the yet inserted row ? ?? ???
int resultId = ((Integer)myRs.getObject( 1)).intValue();
assertEquals("myRs.getObject( 1) (autoincremented id): ",
1, resultId);
String resultSTRING1 = myRs.getString( STRING1);
assertEquals("myRs.getString( STRING1): ",
STRING32CHARS, resultSTRING1);
} catch (SQLException se) {
Exception e = new Exception( se+", Error: "+se.getErrorCode()+", SQLState: "+se.getSQLState());
e.setStackTrace( se.getStackTrace());
//e.initCause( se);
throw e;
}
}
public void testRowDeleted() throws Exception {
System.out.println("testRowDeleted <Bug 4894354>");
System.out.print(" - using: ");
testInsertRow(); // initialize datastore with 1 record
boolean booleanResult;
int resultId;
String resultSTRING1;
try {
myRs.moveToInsertRow();
myRs.updateString( STRING1, UPDATED19CHARS);
myRs.insertRow();
// booleanResult = myRs.rowInserted();
// assertFalse("myRs.rowInserted()): ",
// booleanResult);
myRs.moveToCurrentRow();
resultSTRING1 = myRs.getString( STRING1);
assertEquals("myRs.getString( STRING1): ",
STRING32CHARS, resultSTRING1);
myRs.deleteRow();
booleanResult = myRs.rowDeleted();
assertFalse("myRs.rowDeleted()): ",
booleanResult);
booleanResult = myRs.rowUpdated();
assertFalse("myRs.rowUpdated()): ",
booleanResult);
booleanResult = myRs.rowInserted();
assertFalse("myRs.rowInserted()): ",
booleanResult);
booleanResult = myRs.previous(); // to avoid another bug
booleanResult = myRs.next();
assertTrue("myRs.next()): ",
booleanResult);
resultSTRING1 = myRs.getString( STRING1);
assertEquals("myRs.getString( STRING1): ",
UPDATED19CHARS, resultSTRING1);
resultId = ((Integer)myRs.getObject( 1)).intValue();
assertEquals("myRs.getObject( 1) (autoincremented id): ",
2, resultId);
// try {
// resultSTRING1 = myRs.getString( STRING1);
// assertEquals("myRs.getString( STRING1): ",
// UPDATED19CHARS, resultSTRING1);
// } catch (SQLException se) {
// assertEquals("se.getSQLState() (after myRs.getString( STRING1)): ",
// "24000", se.getSQLState());
// }
// try {
// resultId = ((Integer)myRs.getObject( 1)).intValue();
// assertEquals("myRs.getObject( 1) (autoincremented id): ",
// 1, resultId);
// } catch (SQLException se) {
// assertEquals("se.getSQLState() (after myRs.getObject( 1)): ",
// "24000", se.getSQLState());
// }
} catch (SQLException se) {
Exception e = new Exception( se+", Error: "+se.getErrorCode()+", SQLState: "+se.getSQLState());
e.setStackTrace( se.getStackTrace());
//e.initCause( se);
throw e;
}
}
/*
public static Test suite() {
TestSuite suite = new TestSuite(JdbcOdbcResultSetTest.class);
return suite;
}
public static void main (String[] args) {
junit.textui.TestRunner.run(suite());
}
*/
}
---------- END SOURCE ----------
C:\Programme\Java\jdk1.6.0\bin>java -version
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP-2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Database can be each ODBC-Database. In my TestCase I used MS-Access.
A DESCRIPTION OF THE PROBLEM :
ResultSet#rowDeleted() always results in : java.lang.ArrayIndexOutOfBoundsException: -1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See TestCase in source code section ...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
true, if row was deleted,
false, if row was not deleted.
ACTUAL -
nothing
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.ArrayIndexOutOfBoundsException: -1
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* JdbcOdbcResultSetTest.java
* JUnit based test
*
* Created on 11. Juni 2006, 02:33
*
* $Id: JdbcOdbcResultSetTest.java 83 2006-08-24 20:56:16Z jdk6_JdbcOdbcBugs_ulf $
*/
package sun.jdbc.odbc;
import junit.framework.*;
import java.sql.*;
/**
*
* @author Ulf Zibis, ###@###.###
*/
public class JdbcOdbcResultSetTest extends TestCase {
private static final String URL = "jdbc:odbc:TestData";
private static final String TABLE = "Test1";
private static final String ID = "id";
private static final String STRING1 = "string1";
private static final String INT1 = "int1";
private static final int STRING1_LEN = 100;
private static final String EMPTY_QUERY = "SELECT * FROM "+TABLE+" WHERE "+ID+"=0";
private static final String ORDERED_QUERY = "SELECT * FROM "+TABLE+" ORDER BY "+ID;
private static final String STRING32CHARS = "Here are only 16 + 16 more chars";
private static final String UPDATED19CHARS = "updated to 19 chars";
private static final String INSERTED8CHARS = "inserted";
private Connection myCon = null;
private Statement myStmt;
private JdbcOdbcResultSet myRs;
public JdbcOdbcResultSetTest(String testName) {
super(testName);
System.out.println("Construct JdbcOdbcResultSetTest("+testName+") !!");
}
protected void finalize() throws Throwable {
super.finalize();
try { if (myCon != null) myCon.close(); }
catch (Throwable t) { t.printStackTrace(); }
}
protected void setUp() throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // Obsolete in JDK 6.0
myCon = DriverManager.getConnection( URL);
Statement stmt = myCon.createStatement();
try {
ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM "+TABLE);
rs.next();
//System.out.println( TABLE+" had "+rs.getInt( 1)+" record(s).");
stmt.executeUpdate("DROP TABLE "+TABLE);
}
catch (SQLException se) {
if (se.getErrorCode() == -1305)
System.out.println( TABLE+" was not existent.");
else throw se;
}
stmt.executeUpdate("CREATE TABLE "+TABLE+"( "+ID+" COUNTER PRIMARY KEY, "
+STRING1+" VARCHAR("+STRING1_LEN+"), "
+INT1+" INT)");
//System.out.println("New empty table "+TABLE+" created !");
stmt.close();
myStmt = myCon.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
}
protected void tearDown() throws Exception {
try { if (myCon != null) myCon.close(); myCon = null;}
catch (Throwable t) { t.printStackTrace(); }
}
public void testInsertRow() throws Exception {
System.out.println("testInsertRow()");
try {
myRs = (JdbcOdbcResultSet)myStmt.executeQuery( EMPTY_QUERY);
myRs.next(); // avoid other bug
myRs.moveToInsertRow();
myRs.updateString( STRING1, STRING32CHARS);
myRs.insertRow();
myRs.last(); // Is this allways the yet inserted row ? ?? ???
int resultId = ((Integer)myRs.getObject( 1)).intValue();
assertEquals("myRs.getObject( 1) (autoincremented id): ",
1, resultId);
String resultSTRING1 = myRs.getString( STRING1);
assertEquals("myRs.getString( STRING1): ",
STRING32CHARS, resultSTRING1);
} catch (SQLException se) {
Exception e = new Exception( se+", Error: "+se.getErrorCode()+", SQLState: "+se.getSQLState());
e.setStackTrace( se.getStackTrace());
//e.initCause( se);
throw e;
}
}
public void testRowDeleted() throws Exception {
System.out.println("testRowDeleted <Bug 4894354>");
System.out.print(" - using: ");
testInsertRow(); // initialize datastore with 1 record
boolean booleanResult;
int resultId;
String resultSTRING1;
try {
myRs.moveToInsertRow();
myRs.updateString( STRING1, UPDATED19CHARS);
myRs.insertRow();
// booleanResult = myRs.rowInserted();
// assertFalse("myRs.rowInserted()): ",
// booleanResult);
myRs.moveToCurrentRow();
resultSTRING1 = myRs.getString( STRING1);
assertEquals("myRs.getString( STRING1): ",
STRING32CHARS, resultSTRING1);
myRs.deleteRow();
booleanResult = myRs.rowDeleted();
assertFalse("myRs.rowDeleted()): ",
booleanResult);
booleanResult = myRs.rowUpdated();
assertFalse("myRs.rowUpdated()): ",
booleanResult);
booleanResult = myRs.rowInserted();
assertFalse("myRs.rowInserted()): ",
booleanResult);
booleanResult = myRs.previous(); // to avoid another bug
booleanResult = myRs.next();
assertTrue("myRs.next()): ",
booleanResult);
resultSTRING1 = myRs.getString( STRING1);
assertEquals("myRs.getString( STRING1): ",
UPDATED19CHARS, resultSTRING1);
resultId = ((Integer)myRs.getObject( 1)).intValue();
assertEquals("myRs.getObject( 1) (autoincremented id): ",
2, resultId);
// try {
// resultSTRING1 = myRs.getString( STRING1);
// assertEquals("myRs.getString( STRING1): ",
// UPDATED19CHARS, resultSTRING1);
// } catch (SQLException se) {
// assertEquals("se.getSQLState() (after myRs.getString( STRING1)): ",
// "24000", se.getSQLState());
// }
// try {
// resultId = ((Integer)myRs.getObject( 1)).intValue();
// assertEquals("myRs.getObject( 1) (autoincremented id): ",
// 1, resultId);
// } catch (SQLException se) {
// assertEquals("se.getSQLState() (after myRs.getObject( 1)): ",
// "24000", se.getSQLState());
// }
} catch (SQLException se) {
Exception e = new Exception( se+", Error: "+se.getErrorCode()+", SQLState: "+se.getSQLState());
e.setStackTrace( se.getStackTrace());
//e.initCause( se);
throw e;
}
}
/*
public static Test suite() {
TestSuite suite = new TestSuite(JdbcOdbcResultSetTest.class);
return suite;
}
public static void main (String[] args) {
junit.textui.TestRunner.run(suite());
}
*/
}
---------- END SOURCE ----------