Implicit autocommit?

Поиск
Список
Период
Сортировка
От Eric Faulhaber
Тема Implicit autocommit?
Дата
Msg-id 4699BA51.6050001@goldencode.com
обсуждение исходный текст
Ответы Re: Implicit autocommit?
Список pgsql-jdbc
I am using postgresql-8.1-408.jdbc3.jar w/ PostgreSQL 8.1.8 on Kubuntu
Linux.

Given the following testcase (note autocommit is disabled)...

--------- BEGIN SOURCE -----------
import java.sql.*;

public class VacuumTest
{
   public static void main(String[] args)
   throws SQLException
   {
      Connection conn = null;
      try
      {
         Class.forName("org.postgresql.Driver");
         conn =
DriverManager.getConnection("jdbc:postgresql://localhost/test");
         conn.setAutoCommit(false);

         update(conn, "create temp table tt1 (c1 int4)");
         update(conn, "vacuum tt1");
         update(conn, "drop table tt1");
      }
      catch (Exception exc)
      {
         exc.printStackTrace();
      }
      finally
      {
         if (conn != null)
         {
            conn.close();
         }
      }
   }

   private static void update(Connection conn, String sql)
   throws SQLException
   {
      Statement stmt = conn.createStatement();
      try
      {
         stmt.executeUpdate(sql);
      }
      finally
      {
         stmt.close();
      }
   }
}
---------- END SOURCE ------------

...I see the following result:

org.postgresql.util.PSQLException: ERROR: VACUUM cannot run inside a
transaction block
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:340)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:286)
        at VacuumTest.update(VacuumTest.java:38)
        at VacuumTest.main(VacuumTest.java:16)

I debugged into the driver and found it was issuing a "BEGIN" to the
backend just before each statement.  Why would it do this with
autocommit disabled?

Thanks,
Eric Faulhaber


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: tomasz brymora
Дата:
Сообщение: BLOB, iBatis and PostgreSql
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: Implicit autocommit?