Skip site navigation (1) Skip section navigation (2)

Re: cursor "jdbc_curs_1" does not exist

From: Kris Jurka <books(at)ejurka(dot)com>
To: tmp(at)nitwit(dot)de
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: cursor "jdbc_curs_1" does not exist
Date: 2004-06-15 17:38:26
Message-ID: Pine.BSO.4.56.0406151234060.10395@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-jdbc

On Tue, 15 Jun 2004 tmp(at)nitwit(dot)de wrote:

> On Tuesday 15 June 2004 18:06, you wrote:
> > 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.
> 
> Hmm. And why does this code work then:

It is unclear what the differences here are.  You haven't shown the 
Statement creation and/or execution, so it's possible that you haven't 
used setFetchSize or you've specified a scrollable ResultSet.  Maybe auto 
commit is on.  Any of these will cause a cursor not to be used and the 
results will be fetched in bulk, so an intermediate commit won't cause any 
problems.  Maybe the query doesn't retrieve 100 rows, so it doesn't get to 
the commit part.

Kris Jurka

> 
> 		for( int j = 1; row.next(); j++ )
> 		{
> 			String id = row.getString( "id" );
> 			URL url = new URL( row.getString( "url" ) );
> 			Timestamp time = row.getTimestamp( "timestamp" );
> 
> 			try
> 			{
> 				insertUrls.setString( 1, id );
> 				insertUrls.setString( 2, url.toString() );
> 				insertUrls.setString( 3, resp.getText() );
> 				insertUrls.execute();
> 			}
> 			catch( Exception e )
> 			{
> 				System.err.println( e );
> 			}
> 			finally
> 			{
> 				if( j % 100 == 0 )
> 				{
> 					System.out.println();
> 					f4t.commit();
> 				}
> 			}
> 		}
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
> 

In response to

Responses

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2004-06-15 18:00:00
Subject: Re: Prepare Statement
Previous:From: tmpDate: 2004-06-15 16:53:58
Subject: Re: cursor "jdbc_curs_1" does not exist

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group