Java tutorial
/* * */ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.sql.Timestamp; public class Main { public static void main(String[] args) throws Exception { Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); String sqlQuery = "SELECT uid, name, duration from EVENTS"; ResultSet rs = stmt.executeQuery(sqlQuery); while (rs.next()) { rs.updateString("Name", "new Name"); rs.updateRow(); } rs.first(); while (rs.next()) { String name = rs.getString(2); Timestamp hireDate = rs.getTimestamp(5); System.out.println("Name: " + name + " Hire Date: " + hireDate); } rs.close(); } static Connection conn; static Statement st; static { try { // Step 1: Load the JDBC driver. Class.forName("org.hsqldb.jdbcDriver"); System.out.println("Driver Loaded."); // Step 2: Establish the connection to the database. String url = "jdbc:hsqldb:data/tutorial"; conn = DriverManager.getConnection(url, "sa", ""); System.out.println("Got Connection."); st = conn.createStatement(); } catch (Exception e) { System.err.println("Got an exception! "); e.printStackTrace(); System.exit(0); } } }