Scrolling through cursors
От
Dave Cramer
Тема
Scrolling through cursors
Дата
Msg-id
002901c1ce2f$c4d913b0$807ba8c0@inspiron
Ответ на
Visualization of structure (OT?) (Fredrik Wendt)
Список
Дерево обсуждения
Visualization of structure (OT?) Fredrik Wendt <fredrik.wendt@linux.se>
Re: Visualization of structure (OT?) "Dave Cramer" <Dave@micro-automation.net>
Scrolling through cursors "Dave Cramer" <Dave@micro-automation.net>
Re: Scrolling through cursors Peter V Cooper <pvcooper@adelphia.net>
Re: Scrolling through cursors "Dave Cramer" <Dave@micro-automation.net>
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 ) {}
}
}
В списке pgsql-jdbc по дате отправления