X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 106B8D1B1D9 for ; Tue, 15 Jun 2004 13:06:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49280-09 for ; Tue, 15 Jun 2004 16:06:34 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 2C33ED1B1B7 for ; Tue, 15 Jun 2004 13:06:34 -0300 (ADT) Received: from mail63.csoft.net (unknown [63.111.22.74]) by www.postgresql.com (Postfix) with SMTP id 84549CF49D3 for ; Tue, 15 Jun 2004 13:06:33 -0300 (ADT) Received: (qmail 27792 invoked by uid 1112); 15 Jun 2004 16:06:26 -0000 Date: Tue, 15 Jun 2004 11:06:26 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: tmp@nitwit.de Cc: pgsql-jdbc@postgresql.org Subject: Re: cursor "jdbc_curs_1" does not exist In-Reply-To: <200406151736.27450.tmp@nitwit.de> Message-ID: References: <200406151736.27450.tmp@nitwit.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/53 X-Sequence-Number: 10255 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 >