Listing 1

Statement stmt = conn.createStatement ();

Int rowcount = stmt.executeUpdate ("insert into etable (event) values ('TMM')");

Int rowcount = stmt.executeUpdate ("insert into costs (cost) values (45.0)");

Savepoint sv1 = conn.setSavePoint ("svpoint1");
// create savepoint for inserts

Int rowcount = stmt.executeUpdate ("delete from employees");

Conn.rollback (sv1);
// discard the delete statement but keep the inserts

Conn.commit;
// inserts are now permanent

Listing 2

// Retrieve the case history for incident 71164
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery (
"select CaseHistory from Cases where IncidentID=71164");

rs.next(); // position to the row
Blob data = rs.getClob (1);
// populate our Blob object with the data
Rs.close();

// now letšs insert this history into another table
stmt.setClob (1, data);
// data is Clob object we retrieved from the history table

int InsertCount = stmt.executeUpdate (
"insert into EscalatedIncidents (IncidentID, CaseHistory, Owner)"
+ " Values (71164, ?, ('Goodson') ");

// wešre done ... CLOB data is now in the database

Listing 3

// get ready to call the employeeInfo procedure
CallableStatement cstmt = conn.prepareCall ("{call employeeInfo (?)}");

Cstmt.setInt (1,71164);
// bind parameter info for employee with id 71164

Boolean RetCode = Cstmt.execute ();
// call the procedure
// For simplicity wešll bypass logic for the procedure possibly returning update counts

// first result set will be discarded ...
materialize it and immediately move to the second ResultSet DiscardRS = cstmt.getResultSet();
// materialize first result set

ResultSet EmpListRS = cstmt.getMoreResults ();
// by default, close DiscardRS
// the 2nd result set: list of employees that report to 71164 is now available

ResultSet ProjectsRS = cstmt.getMoreResults (KEEP_CURRENT_RESULT);
// the 3rd result set is now materialized and we can simultaneously operate on both
// the employee list and the project list