int rows = 0;
ResultSet rslt = null;
Statement stmt = null;
try {
stmt = conn.createStatement();
rslt = stmt.executeQuery(
"select code, " +
" description, " +
" inactive_date " +
"from PERSON_IDENTIFIER_TYPE");
System.out.println("type = " +
formatType(stmt.getResultSetType()));
System.out.println("concurrency = " +
formatConcurrency(stmt.getResultSetConcurrency()));
System.out.println("before first = " +
new Boolean(rslt.isBeforeFirst()).toString());
while (rslt.next()) {
rows++;
if (rslt.isFirst())
System.out.println("the first row = " + Integer.toString(rows));
// Contrary to JDBC API doc, but in accordance with Oracle's doc
//if (rslt.isLast())
// System.out.println("the last row = " + Integer.toString(rows));
}
System.out.println("after last = " +
new Boolean(rslt.isAfterLast()).toString());
System.out.println(Integer.toString(rows) + " rows selected");
System.out.println(" ");
rslt.close();
rslt = null;
stmt.close();
stmt = null;
}
catch (SQLException e) {
System.err.println(e.getMessage());
}
finally {
if (rslt != null)
try { rslt.close(); } catch (SQLException ignore) { }
if (stmt != null)
try { stmt.close(); } catch (SQLException ignore) { }
}
rows = 0;
try {
stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rslt = stmt.executeQuery(
"select code, " +
" description, " +
" inactive_date " +
"from PERSON_IDENTIFIER_TYPE");
System.out.println("type = " +
formatType(stmt.getResultSetType()));
System.out.println("concurrency = " +
formatConcurrency(stmt.getResultSetConcurrency()));
System.out.println("before first = " +
new Boolean(rslt.isBeforeFirst()).toString());
while (rslt.next()) {
rows++;
if (rslt.isFirst())
System.out.println("the first row = " + Integer.toString(rows));
if (rslt.isLast())
System.out.println("the last row = " + Integer.toString(rows));
}
System.out.println("after last = " +
new Boolean(rslt.isAfterLast()).toString());
System.out.println(Integer.toString(rows) + " rows selected");
if (rslt.previous())
System.out.println("the prev row = " +
Integer.toString(rslt.getRow()));
if (rslt.relative(-1))
System.out.println("rel -1 row = " +
Integer.toString(rslt.getRow()));
if (rslt.absolute(2))
System.out.println("abs 2 row = " +
Integer.toString(rslt.getRow()));
rslt.beforeFirst();
System.out.println("bef first row = " +
Integer.toString(rslt.getRow()));
if (rslt.first())
System.out.println("first row = " +
Integer.toString(rslt.getRow()));
if (rslt.last())
System.out.println("last row = " +
Integer.toString(rslt.getRow()));
rslt.afterLast();
System.out.println("aft last row = " +
Integer.toString(rslt.getRow()));
System.out.println(" ");
rslt.close();
rslt = null;
stmt.close();
stmt = null;
}
catch (SQLException e) {
System.err.println(e.getMessage());
}
finally {
if (rslt != null)
try { rslt.close(); } catch (SQLException ignore) { }
if (stmt != null)
try { stmt.close(); } catch (SQLException ignore) { }
}