From: | Eric Faulhaber <ecf(at)goldencode(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Implicit autocommit? |
Date: | 2007-07-15 06:10:25 |
Message-ID: | 4699BA51.6050001@goldencode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2007-07-15 11:07:34 | Re: Implicit autocommit? |
Previous Message | tomasz brymora | 2007-07-13 18:45:25 | BLOB, iBatis and PostgreSql |