Basic HTML version of Foils prepared June 5 99

Foil 75 Database queries

From Java Language in the Computer Science Curriculum ADMI Tutorial Duluth Minnesota -- June 3 99. by Geoffrey C. Fox


1 There are several classes for making SQL statements.
  • Statement stmt = conn.createStatement( ); ResultSet rs = stmt.executeQuery("select a,b,c from table1");
2 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); }
3 SQL statements may insert, update and delete, and may execute stored procedures in the database. Additional classes deal with transaction commit and rollback.

in Table To:


© 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 Sat Jun 5 1999