Cursor problems - Mailing list pgsql-jdbc

From Jeffrey Melloy
Subject Cursor problems
Date
Msg-id 083DBFCC-8EAC-4A5F-BD61-3A82DFC45E5E@visualdistortion.org
Whole thread Raw
Responses Re: Cursor problems
List 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

pgsql-jdbc by date:

Previous
From: Mark Lewis
Date:
Subject: Re: Encoding
Next
From: Oliver Jowett
Date:
Subject: Re: Cursor problems