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 6FF19D1B1CE for ; Wed, 14 Jul 2004 14:00:23 -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 21969-10 for ; Wed, 14 Jul 2004 17:00:05 +0000 (GMT) Received: from ms1.city.ac.uk (ms1.city.ac.uk [138.40.12.21]) by svr1.postgresql.org (Postfix) with ESMTP id D60E4D1B1AA for ; Wed, 14 Jul 2004 14:00:03 -0300 (ADT) Received: from mailswitch.city.ac.uk ([138.40.12.12] helo=mailswitch) by ms1.city.ac.uk with smtp (Exim 4.20) id 1Bkn6M-0005Fn-PU for pgsql-jdbc@postgresql.org; Wed, 14 Jul 2004 17:59:26 +0100 Received: from webmail ([138.40.12.22] helo=ms2.city.ac.uk) by mailswitch with esmtp (Exim 3.16 #5) id 1Bkn6M-0002JB-00 for pgsql-jdbc@postgresql.org; Wed, 14 Jul 2004 17:59:26 +0100 Received: from prayer by ms2.city.ac.uk with local (Exim 3.36 #8) id 1Bkn6M-00020F-00 for pgsql-jdbc@postgresql.org; Wed, 14 Jul 2004 17:59:26 +0100 From: Vladimir Stankovic To: pgsql-jdbc@postgresql.org Subject: No exception with concurrent updates Date: 14 Jul 2004 17:59:25 +0100 X-Mailer: Prayer v1.0 X-Originating-IP: [138.40.26.123] Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 Message-Id: X-MailScanner-Information: Please contact Computing Services for more information X-City-MailScanner: Found to be clean X-City-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=0, required 5) 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: 200407/156 X-Sequence-Number: 10540 Dear all, I wrote (extremely) simple programme in Java (jsdk1.4.2) to examine the PostgreSQL's (v7.2.4, I know, rather obsolete) handling of concurrent updates and I'm confused with the fact that the server (running on a remote machine with Red Hat Linux 6.0) does not give me any kind of exception when I execute the following code on the client machine running Win 2000. While running the programme in the debug mode the excution just hangs when the UPDATE query of the transaction2() is executed. Using setQueryTimeout() won't help much since it is available as of 7.3 version, isn't it. I set autocommit off and specify TRANSACTION_SERIALIZABLE on the Connection objects. I'm using the pg73jdbc3.jar and NetBeans 3.5. /* * ConcurencyTest.java * Created on 09 July 2004, 15:39 */ import java.sql.*; public class ConcurrencyTest { Connection con1, con2; public ConcurrencyTest() { /* ConnectionManager object creates Connection and the GetConnection() method returns the reference. Value of 128 specifies the JDBC connection (rather than ODBC). */ con1 = new ConnectionManager(128).GetConnection(); con2 = new ConnectionManager(128).GetConnection(); transaction1(); transaction2(); try { con2.commit(); con1.commit(); //con1.close(); //con2.close(); } catch (SQLException sqle) { System.out.println("Could not close the connection"); } } public void transaction1() { try { con1.commit(); Statement sta1 = con1.createStatement(); sta1.setQueryTimeout(5); rs_1 = sta1.executeQuery("SELECT * FROM Orderline WHERE ol_o_id = 1 AND ol_d_id = 1 AND ol_w_id = 1 AND ol_number = 4"); while (rs_1.next()) System.out.println(rs_1.getInt(8) + "\tT1"); rs_1.close(); sta1.executeUpdate("UPDATE Orderline SET ol_quantity = 10 WHERE ol_o_id = 1 AND ol_d_id = 1 AND ol_w_id = 1 AND ol_number = 4"); sta1.close(); } catch (SQLException sqle) { System.out.println("Error in Transaction 1: " + sqle); } } public void transaction2() { try { con2.commit(); Statement sta2 = con2.createStatement(); sta2.setQueryTimeout(5); ResultSet rs_2 = sta2.executeQuery("SELECT * FROM Orderline WHERE ol_o_id = 1 AND ol_d_id = 1 AND ol_w_id = 1 AND ol_number = 4"); while (rs_2.next()) System.out.println(rs_2.getInt(8) + "\tT2"); rs_2.close(); sta2.executeUpdate("UPDATE Orderline SET ol_quantity = 20 WHERE ol_o_id = 1 AND ol_d_id = 1 AND ol_w_id = 1 AND ol_number = 4"); sta2.close(); } catch (SQLException sqle) { System.out.println("Error in Transaction 2: " + sqle); } } public static void main(String args[]) { new ConcurrencyTest(); } }