2 messages in org.postgresql.pgsql-jdbcCursor problems
FromSent OnAttachments
Jeffrey MelloyJul 8, 2006 1:27 pm 
Oliver JowettJul 8, 2006 2:55 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Cursor problemsActions...
From:Jeffrey Melloy (jmel@visualdistortion.org)
Date:Jul 8, 2006 1:27:14 pm
List:org.postgresql.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