From: | Jeffrey Melloy <jmelloy(at)visualdistortion(dot)org> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Cursor problems |
Date: | 2006-07-08 20:27:37 |
Message-ID: | 083DBFCC-8EAC-4A5F-BD61-3A82DFC45E5E@visualdistortion.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
I was having trouble doing checkpoint commits on a cursor. It's
possible I'm misunderstanding something basic, but it seems like
commiting on the same connection a cursor is on breaks the cursor.
Here's a pared-down snippet of code giving me the problem:
conn.setAutoCommit(false);
pstmt = conn.prepareStatement("SELECT crash_id FROM
crash.crash_logs");
pstmt.setFetchSize(50);
rs = pstmt.executeQuery();
pstmt = conn.prepareStatement("insert into blah " +
"values (?)");
while(rs.next()) {
pstmt.setInt(1, rs.getInt("crash_id"));
pstmt.executeUpdate();
if(rs.getRow() % 50 == 0) {
System.out.println("Committing " + rs.getRow());
conn.commit();
}
}
conn.commit();
When I run it, I get the following error after the commit:
ERROR: portal "C_3" does not exist
I solved it by using two separate connections, but I'm not sure if
this is a bug or a misunderstanding on my part.
Jeff
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2006-07-08 21:55:34 | Re: Cursor problems |
Previous Message | Mark Lewis | 2006-07-07 20:08:45 | Re: Encoding |