/* Question answered */
Hi, I am using Eclipse 3.6.1 (Helios) and I work with SQLite database through JDBC interface. The problem is that I'm getting different result under Debug and Run modes. Here is the test case:
public static void main(String[] args){
String db_name = /* path to some SQLite database */;
try {
// If we using ch-werner SQLite Java Wrapper/JDBC Driver
Class.forName("SQLite.JDBCDriver");
// If we using Xerial or Zentus impl.
Class.forName("org.sqlite.JDBC");
Connection con = DriverManager.getConnection("jdbc:sqlite:" + db_name);
Statement statement = con.createStatement();
ResultSet rs;
try {
rs = statement.executeQuery("SELECT * FROM sites;");
boolean flag = rs.isBeforeFirst(); // Breakpoint here
System.out.println(flag);
if (flag) rs.next();
System.out.println(rs.getObject(1));
} finally {
statement.close();
con.close();
}
} catch(Exception ex) {
ex.printStackTrace();
}
}
I tried JDK 1.6.0, 1.6.0_23, JRE 1.6.0; 3 implementations of JDBC-SQLite: ch-werner SQLite Java Wrapper/JDBC Driver (r2011-01-06), Zentus SQLiteJDBC (0.5.6) and Xerial SQLite JDBC Driver (which is extended Zentus, tried 3.6.20 and 3.7.2) for different SQLite test databases.
If I run this under Run configuration, it works fine (prints true
and desired object), but when I try step-by-step debugging (using breakpoint, followed by Step Over's), it always prints false and getObject
fails for different reasons (java.lang.ArrayIndexOutOfBoundsException: 2 >= 1
under ch-werner impl, and java.lang.IllegalStateException: SQLite JDBC: inconsistent internal state
under two others). There is no JVM arguments set, just code from scratch. I failed to reprofuce this bug under NetBeans 6.9.
Am I doing something wrong or what?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…