The piece of code below illustrates an issue with the servlet.
The servlet always runs without abending....but it will only either make one 'insertion' OR it will open the database and do the retrieval into a result set....but will not do both in the same execution. Further, when 'inserting' it will only do one insert, the 2nd and 3rd are ignored and it goes to 'close' the connection without doing the retrieval either. If I comment out the 'insertions' and re-compile, it will then do a retrieval into the resultset. So....it will only do one function per run and will not 'fall into' and do anythng else for a given run. Is this a Java language usage issue.....or a problem with the 'sqliteJDBC' JNI classes I am using ?
Connection conn = DriverManager.getConnection("jdbc:sqlite:"+fileName);
// Create a Statement object for the database connection,
Statement stmt = conn.createStatement();
stmt.executeQuery("INSERT INTO name values('John','Dutcher', 0001)");
stmt.executeQuery("INSERT INTO name values('John', Dutcher', 0002)");
stmt.executeQuery("INSERT INTO name values('John', Dutcher', 0003)");
// Create a result set object for the statement
ResultSet rs = stmt.executeQuery("SELECT * FROM name");
// Iterate the result set, printing each column
while (rs.next()) {
String fn = rs.getString("first_name"); // Column 1
String ln = rs.getString("last_name"); // Column 2
String regnbr = rs.getString("regnbr"); // Column 3
out.println("First Name: "+fn+" Last Name: "+ln+" Registration #: "+regnbr);
}
// Close the result set
rs.close();
// Close the connection
conn.close();
The servlet always runs without abending....but it will only either make one 'insertion' OR it will open the database and do the retrieval into a result set....but will not do both in the same execution. Further, when 'inserting' it will only do one insert, the 2nd and 3rd are ignored and it goes to 'close' the connection without doing the retrieval either. If I comment out the 'insertions' and re-compile, it will then do a retrieval into the resultset. So....it will only do one function per run and will not 'fall into' and do anythng else for a given run. Is this a Java language usage issue.....or a problem with the 'sqliteJDBC' JNI classes I am using ?
Connection conn = DriverManager.getConnection("jdbc:sqlite:"+fileName);
// Create a Statement object for the database connection,
Statement stmt = conn.createStatement();
stmt.executeQuery("INSERT INTO name values('John','Dutcher', 0001)");
stmt.executeQuery("INSERT INTO name values('John', Dutcher', 0002)");
stmt.executeQuery("INSERT INTO name values('John', Dutcher', 0003)");
// Create a result set object for the statement
ResultSet rs = stmt.executeQuery("SELECT * FROM name");
// Iterate the result set, printing each column
while (rs.next()) {
String fn = rs.getString("first_name"); // Column 1
String ln = rs.getString("last_name"); // Column 2
String regnbr = rs.getString("regnbr"); // Column 3
out.println("First Name: "+fn+" Last Name: "+ln+" Registration #: "+regnbr);
}
// Close the result set
rs.close();
// Close the connection
conn.close();