The Artima Developer Community
Sponsored Link

Java Answers Forum
Java servlet using sqliteJDBC JNI

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
John Dutcher

Posts: 1
Nickname: jfdutcher
Registered: Mar, 2007

Java servlet using sqliteJDBC JNI Posted: Mar 28, 2007 4:02 PM
Reply to this message Reply
Advertisement
The code snippet below helps illustrate a problem whose core cause I am trying to determine. The servlet will always open a connection and will create a statement for insertion(s) as shown; however ...it will not both do the insertion 'and' do the resultset....plus when inserting....it will insert only one row....it will not insert more than one....and having inserted one row....it will not open the result set and retrieve the table content. Only one function seems doable at a time....either insert(one row only) or retrieve the table.
(The servlet does not abend).

Is this a function of Java (as written) or an issue with the sqliteJDBC class(es) I am using to include SQLite in the servlet ?

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();

Topic: Java servlet using sqliteJDBC  JNI Previous Topic   Next Topic Topic: manifest.mf class-path too wide?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use