-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP-2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested with Microsoft Access database.
A DESCRIPTION OF THE PROBLEM :
After Statement#executeQuery("SELECT COUNT(*) FROM "+TABLE) ResultSet#next() returns false, if resultset is of ( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE).
See source code below
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create new DB table "Test1"
myCon = DriverManager.getConnection("jdbc:odbc:TestData");
Statement stmt_ = myCon.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet myRs = stmt_.executeQuery("SELECT COUNT(*) FROM Test1");
System.out.println( myRs.next());
See also source code below
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* JdbcOdbcResultSetTest.java
* JUnit based test
*
* Created on 11. Juni 2006, 02:33
*/
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 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(100), "
+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 testSQLCount() throws Exception {
System.out.println("testSQLCount()");
try {
Statement stmt_ = myCon.createStatement();
myRs = (JdbcOdbcResultSet)stmt_.executeQuery("SELECT COUNT(*) FROM "+TABLE);
assertTrue("myRs.next(): ",
myRs.next());
int resultId = myRs.getInt( 1);
assertTrue("myRs.getInt( 1) ('SELECT COUNT(*) ...') >= 0: ",
resultId >= 0);
stmt_.close();
myRs = (JdbcOdbcResultSet)myStmt.executeQuery("SELECT COUNT(*) FROM "+TABLE);
assertTrue("myRs.next() ( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE): ",
myRs.next());
resultId = myRs.getInt( 1);
assertTrue("myRs.getInt( 1) ('SELECT COUNT(*) ...') >= 0: ",
resultId >= 0);
} 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 ----------
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP-2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested with Microsoft Access database.
A DESCRIPTION OF THE PROBLEM :
After Statement#executeQuery("SELECT COUNT(*) FROM "+TABLE) ResultSet#next() returns false, if resultset is of ( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE).
See source code below
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create new DB table "Test1"
myCon = DriverManager.getConnection("jdbc:odbc:TestData");
Statement stmt_ = myCon.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet myRs = stmt_.executeQuery("SELECT COUNT(*) FROM Test1");
System.out.println( myRs.next());
See also source code below
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* JdbcOdbcResultSetTest.java
* JUnit based test
*
* Created on 11. Juni 2006, 02:33
*/
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 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(100), "
+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 testSQLCount() throws Exception {
System.out.println("testSQLCount()");
try {
Statement stmt_ = myCon.createStatement();
myRs = (JdbcOdbcResultSet)stmt_.executeQuery("SELECT COUNT(*) FROM "+TABLE);
assertTrue("myRs.next(): ",
myRs.next());
int resultId = myRs.getInt( 1);
assertTrue("myRs.getInt( 1) ('SELECT COUNT(*) ...') >= 0: ",
resultId >= 0);
stmt_.close();
myRs = (JdbcOdbcResultSet)myStmt.executeQuery("SELECT COUNT(*) FROM "+TABLE);
assertTrue("myRs.next() ( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE): ",
myRs.next());
resultId = myRs.getInt( 1);
assertTrue("myRs.getInt( 1) ('SELECT COUNT(*) ...') >= 0: ",
resultId >= 0);
} 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 ----------