Basic HTML version of Foils prepared July 6 99

Foil 64 Database queries

From Use of Java Language in Computational Science DoD Modernization Users Group Conference Monterey -- June 7 99. by Nancy McCracken, Geoffrey C. Fox


There are several classes for making SQL statements.
  • Statement stmt = conn.createStatement( ); ResultSet rs = stmt.executeQuery("select a,b,c from table1");
The query returns a result set, which has database table rows satisfying the query.
  • while (rs.next( )) { //print values for current row int i = r.getInt("a"); double f = r.getDouble("b"); String s = r.getString("c"); System.out.println("row" + i + f + s); }
SQL statements may insert, update and delete, and may execute stored procedures in the database. Additional classes deal with transaction commit and rollback.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Jul 6 1999