Frozen Spider Frozen Spider - 1 year ago 67
Java Question

Different results during Debug and Run configurations of JDBC-SQLite app

/* 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

// If we using Xerial or Zentus impl.

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
if (flag);
} finally {
} catch(Exception ex) {

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
and desired object), but when I try step-by-step debugging (using breakpoint, followed by Step Over's), it always prints false and
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?

Answer Source

What happens if you use the debug configuration, but just hit "go" (or whatever Netbeans uses) instead of stepping over each line one by one?

My guess is that you've got a watch which is evaluating some method with side-effects (e.g. and screwing up the state of the application as you step over lines.