Received: from flex.flex.ro (IDENT:root@[193.230.255.4]) by hub.org (8.9.2/8.9.1) with ESMTP id GAA56599 for ; Thu, 15 Apr 1999 06:41:39 -0400 (EDT) (envelope-from teo@flex.ro) Received: from flex.ro (IDENT:teo@teo.flex.ro [193.230.255.3]) by flex.flex.ro (8.9.1/8.9.1) with ESMTP id MAA23233 for ; Thu, 15 Apr 1999 12:40:37 +0300 Sender: teo@flex.flex.ro Message-ID: <3715C329.9739047D@flex.ro> Date: Thu, 15 Apr 1999 10:44:57 +0000 From: Constantin Teodorescu Organization: FLEX Consulting X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5 i586) X-Accept-Language: en MIME-Version: 1.0 To: PostgreSQL Interfaces Subject: JDBC (executing transactions coding style) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I want to execute multiple SQL commands (also insert,updates and selects ) in a transaction block. Is the following coding style correct ? Statement st; ResultSet rs; try { st.executeUpdate("BEGIN"); st.executeUpdate("INSERT INTO ..."); st.executeUpdate("DELETE FROM ..."); rs = st.executeQuery("SELECT FROM ..."); if (rs != null) { while ( rs.next() ) { // do different things } } rs.close(); st.executeUpdate("UPDATE ..."); st.executeUpdate("COMMIT TRANSACTION"); } catch (SQLException sqle) { sqle.printStackTrace(); // ABORT TRANSACTION NEEDED ? } What I want to know : is there necessary to do a st.executeUpdate("ABORT TRANSACTION") in the catch instruction block ? I recall that someone says that an error inside a transaction block automatically aborts the transaction. Is it true ? It works here ? For other databases it might be necessary to do that. Then, the st.executeUpdate("ABORT"); must be included also in another try..catch block, true ? Thanks a lot, -- Constantin Teodorescu FLEX Consulting Braila, ROMANIA