Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XK7sK-0001ob-77 for pgsql-jdbc@arkaria.postgresql.org; Wed, 20 Aug 2014 15:32:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XK7sJ-0001WR-LK for pgsql-jdbc@arkaria.postgresql.org; Wed, 20 Aug 2014 15:32:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XK7sI-0001V7-JU for pgsql-jdbc@postgresql.org; Wed, 20 Aug 2014 15:32:34 +0000 Received: from smtp03.smtpout.orange.fr ([80.12.242.125] helo=smtp.smtpout.orange.fr) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XK7sE-0007BJ-P2 for pgsql-jdbc@postgresql.org; Wed, 20 Aug 2014 15:32:33 +0000 Received: from zimbra.cy.cassidian.net ([90.11.255.140]) by mwinf5d58 with ME id h3YV1o00W32XWDm033YWrv; Wed, 20 Aug 2014 17:32:30 +0200 X-ME-Helo: zimbra.cy.cassidian.net X-ME-Date: Wed, 20 Aug 2014 17:32:30 +0200 X-ME-IP: 90.11.255.140 Received: from zimbra.cy.cassidian.net (zimbra.cy.cassidian.net [192.50.50.220]) by zimbra.cy.cassidian.net (Postfix) with ESMTP id F21EC82CBD6 for ; Wed, 20 Aug 2014 16:22:36 +0200 (CEST) Date: Wed, 20 Aug 2014 16:22:36 +0200 (CEST) From: Christophe Canovas To: pgsql-jdbc@postgresql.org Message-ID: <17182522.45.1408544556320.JavaMail.root@zimbra.cy.cassidian.net> In-Reply-To: <10564239.43.1408541952917.JavaMail.root@zimbra.cy.cassidian.net> Subject: Re: Cursors removed with commit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.50.50.52] X-Mailer: Zimbra 6.0.8_GA_2661 (ZimbraWebClient - SAF3 (Linux)/6.0.8_GA_2661) X-Pg-Spam-Score: -1.6 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org To be more explicit, here is my example : private void displayMem() { Runtime rt =3D Runtime.getRuntime(); long alloue =3D rt.totalMemory(); long libre =3D rt.freeMemory(); System.out.println("Free mem =3D " + libre + " / allocated =3D " + allo= ue); } =20=20 public void testJdbcSRS() throws Exception { String driver =3D "org.postgresql.Driver"; Class.forName(driver); String acces =3D "jdbc:postgresql:///"; Connection con =3D java.sql.DriverManager.getConnection(acces, "", ""); con.setAutoCommit(false); =20=20=20=20 Statement st =3D con.createStatement(ResultSet.TYPE_FORWARD_ONLY, Resul= tSet.CONCUR_READ_ONLY);//,ResultSet.HOLD_CURSORS_OVER_COMMIT); st.setFetchSize(10); displayMem(); ResultSet rs =3D st.executeQuery("SELECT * FROM doc_index"); for (int i =3D 0 ; i < 100; i++) { rs.next(); } displayMem(); // Statement st2 =3D con.createStatement(); // st2.execute("DELETE FROM doc_index WHERE id=3D100"); // st2.execute("INSERT INTO doc_index(id,version) VALUES (100,1)"); // con.commit(); for (int i =3D 0 ; i < 100; i++) { rs.next(); } displayMem(); rs.close(); st.close(); con.close(); } First run : OK Remove the comments on lines on Statement st2 =3D ... to con.commit() =3D=3D> cursor error (in that case the same table is updated, but i've tried on another table,= and it's the same behavior) Try to HOLD_CURSORS_OVER_COMMIT : it works, BUT the fetch is not used anymo= re ; the whole table is loaded in the memory (and in my case : OutOfMemory) Regards, Christophe ----- Mail original ----- De: "Christophe Canovas" =C3=80: pgsql-jdbc@postgresql.org Envoy=C3=A9: Mercredi 20 Ao=C3=BBt 2014 15:39:12 Objet: [JDBC] Cursors removed with commit Hello, I have a problem with my huge database ; using cursors (so using a transact= ion with noautocommit, statement with type_forward_only) make cursors remov= ed if I update and save (commit) database values in the same transaction du= ring the fetch loop. Error message is : portal "C_03" doesn't exist All is fine if the commit is done in a different transaction. In more details, in the statement creation : con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ON= LY, ResultSet.HOLD_CURSORS_OVER_COMMIT); the last parameter seems to have no effect ... ? Best Regards, Christophe --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc