pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: tmp@nitwit.de
Cc: pgsql-jdbc@postgresql.org
Subject: Re: cursor "jdbc_curs_1" does not exist
Date: Tue, 15 Jun 2004 11:06:26 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0406151102540.13010@leary.csoft.net> (raw)
In-Reply-To: <200406151736.27450.tmp@nitwit.de>
References: <200406151736.27450.tmp@nitwit.de>



On Tue, 15 Jun 2004 tmp@nitwit.de wrote:

> Hi!
> 
> org.postgresql.util.PSQLException: ERROR: cursor "jdbc_curs_1" does not exist
> 
> Can somebody explain this exception? What I do is pretty simple: I read text 
> from one table, gzip it and insert it into another table. But it seems that 
> the exception is thrown at ResulSet.next() but I'm not sure. Here's the code 
> anyway:

The problem here is that you commit every 100 rows.  A commit closes any 
open cursors, so the next time you try to call next the cursor isn't there 
any more.

Kris Jurka


> 
> 
> 		final PreparedStatement select = f4t.prepareStatement( "SELECT urlid, html 
> FROM html" );
> 		final PreparedStatement insert = f4t.prepareStatement( "INSERT INTO 
> legacy.zhtml (id, zhtml) VALUES (?, ?)" );
> 
> 		f4t.setAutoCommit( false );
> 
> 		select.setFetchSize( FETCH_SIZE );
> 
> 		int i = 0;
> 		for( ResultSet row = select.executeQuery(); row.next(); )
> 		{
> 			final String id = row.getString( "urlid" );
> 			final String html = row.getString( "html" );
> 
> 			final ByteArrayOutputStream bos = new ByteArrayOutputStream();
> 			final DataOutputStream dos = new DataOutputStream( bos );
> 
> 			WritableUtils.writeCompressedString( dos, html );
> 
> 			insert.setString( 1, id );
> 			insert.setBytes( 2, bos.toByteArray() );
> 			insert.execute();
> 
> 			System.out.print( '.' );
> 
> 			if( ++i % 100 == 0 )
> 			{
> 				System.out.println();
> 				f4t.commit();
> 			}
> 		}
> 
> 		f4t.commit();
> 		f4t.setAutoCommit( true );
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
> 



view thread (8+ messages)  latest in thread

Message-ID: <Pine.BSO.4.56.0406151102540.13010@leary.csoft.net>
Permalink:  ../Pine.BSO.4.56.0406151102540.13010@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.56.0406151102540.13010@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, tmp@nitwit.de
  Subject: Re: cursor "jdbc_curs_1" does not exist
  In-Reply-To: <Pine.BSO.4.56.0406151102540.13010@leary.csoft.net>
  References: <200406151736.27450.tmp@nitwit.de> <Pine.BSO.4.56.0406151102540.13010@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox