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

JDBC (executing transactions coding style)

From: Constantin Teodorescu <teo(at)flex(dot)ro>
To: PostgreSQL Interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: JDBC (executing transactions coding style)
Date: 1999-04-15 10:44:57
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
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("INSERT INTO ...");
  st.executeUpdate("DELETE FROM ...");
  rs = st.executeQuery("SELECT FROM ...");
  if (rs != null) {
     while ( ) {
       // do different things
  st.executeUpdate("UPDATE ...");
  st.executeUpdate("COMMIT TRANSACTION");
} catch (SQLException sqle) {

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


pgsql-interfaces by date

Next:From: adminDate: 1999-04-15 12:29:21
Subject: JDBC and Postgres
Previous:From: Constantin TeodorescuDate: 1999-04-15 08:26:44
Subject: Re: [INTERFACES] pg_get_view unknow ...

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