WARNING on setAutoCommit - Mailing list pgsql-jdbc

From Daichi Ueura
Subject WARNING on setAutoCommit
Date
Msg-id 20030308144042.3EA0.DAICHI@lifeflow.jp
Whole thread Raw
Responses Re: WARNING on setAutoCommit
List pgsql-jdbc
Hi,

The following warning is shown on postgres log when you use
JDBC driver; Build 108, for PostgreSQL 7.3.x.

This is the server condition I use:
----------------------------------------
  PostgreSQL  7.3.2
  JDBC        pg73jdbc3.jar(Build 108)
  J2SE        1.4.1_01
  RedHatLinux 7.2
----------------------------------------

When "auto commit" is set true, and I run Connection.setAutoCommit(false)
command in JDBC program, the following warning is shown on the PostgreSQL log;

     WARNING:  COMMIT: no transaction in progress

Because of the warning, I looked at
org.postgresql.jdbc1.AbstractJdbc1Connection#setAutoCommit(), and this program
was written as follows;

     if (this.autoCommit == autoCommit)
         return;
     if (autoCommit)
     {
         if (haveMinimumServerVersion("7.3"))
         {
             //We do the select to ensure a transaction is in process
             //before we do the commit to avoid warning messages
             //from issuing a commit without a transaction in process
             execSQL("select 1; commit; set autocommit = on;");
         }
         else
         {
             execSQL("end");
         }
     }

At the command line; execSQL("select 1; commit; set autocommit = on;");,
the program must finish and not record "warning" in the log even though
the program processes either during or at the end of the transaction.
As a matter of fact, the warning appears when the program runs "commit;."
The program doesn't begin a new transaction even though "select 1;"
has been executed,

I think if we change the command as follows,

execSQL("select 1;");
execSQL("commit; set autocommit = on;");

we can finish the transaction without the warning.

┛
  ┛ Daichi Ueura
┛
  ┛ Hiroshima City Univ, Department of Intelligent Systems.
┛    e-mail: (Private) daichi@lifeflow.jp
  ┛        : (Office)  daichi@neu.co.jp
┛          : (Univ)    g23010@cr.info.hiroshima-cu.ac.jp
  ┛
┛


pgsql-jdbc by date:

Previous
From: "Brian Harris"
Date:
Subject: java.net.SocketException
Next
From: "Larry D. Johnson"
Date:
Subject: Recommended Data Mappings