beaTunes, it sounds like you want cursors but I don't think h2
supports them.
Here is a code sample that uses derby and cursors to navigate a
ResultSet.
Connection connection = DriverManager.getConnection
("jdbc:derby:/temp/db");
connection.setAutoCommit(false);
// Log has over 200,000 records in it.
PreparedStatement statement = connection.prepareStatement(
"select * from log", ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
// Grab results 1000 to 1050
ResultSet resultSet = statement.executeQuery();
resultSet.absolute(1000);
for (int i = 0; i <= 50; i++) {
String text = resultSet.getString("text");
System.out.println(text);
resultSet.next();
}
resultSet.absolute(1200);
for (int i = 0; i <= 50; i++) {
String text = resultSet.getString("text");
System.out.println(text);
resultSet.next();
}
resultSet.absolute(100);
for (int i = 0; i <= 50; i++) {
String text = resultSet.getString("text");
System.out.println(text);
resultSet.next();
}
resultSet.close();
statement.close();
connection.rollback();
connection.close();
// Shutdown derby
try {
DriverManager.getConnection("jdbc:derby:;shutdown=true");
}
catch (SQLException e) {
if (e.getErrorCode() != 50000) {
throw e;
}
}
Brish
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---