Fredik
Here is some code which uses cursors
Dave
public void testCursor()
{
Connection con = null;
try {
con = getConnection();
// cursors work inside a transaction
con.setAutoCommit(false);
Statement stmt = con.createStatement();
// sufficiently long select as to get us something we can scroll
through
stmt.execute("declare cursorname cursor for select * from
pg_class");
ResultSet rs = stmt.executeQuery("fetch 10 from cursorname");
while (rs.next()){
System.out.println(rs.getString(1));
}
rs.close();
// close the cursor
con.commit();
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
try {
if ( con != null )
con.close();
}catch ( SQLException ex ) {}
}
}