From: | "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> |
---|---|
To: | "Oliver Jowett" <oliver(at)opencloud(dot)com>, "Quartz" <quartz12h(at)yahoo(dot)com> |
Cc: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: JDBC gripe list (the autocommit subthread) |
Date: | 2011-03-31 23:06:17 |
Message-ID: | 4D94C299020000250003C0A7@gw.wicourts.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Oliver Jowett <oliver(at)opencloud(dot)com> wrote:
> (b) the current behavior is consistent with how multiple statement
> execution works elsewhere in the driver, where if you execute
> "SELECT a; SELECT b" as a statement with autocommit=true then the
> two queries run in a single transaction;
I did not know that. Is that required by spec?
It definitely doesn't happen in psql:
test=# select now(); select now();
now
-------------------------------
2011-03-31 17:38:41.345244-05
(1 row)
now
-------------------------------
2011-03-31 17:38:41.410403-05
(1 row)
test=# begin; select now(); select now(); commit;
BEGIN
now
-------------------------------
2011-03-31 17:38:58.593238-05
(1 row)
now
-------------------------------
2011-03-31 17:38:58.593238-05
(1 row)
COMMIT
I would have expected more or less the same from this:
import java.sql.*;
public class MultiStmt
{
public static void main(String[] args) throws Exception
{
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection
("jdbc:postgresql:test", "kgrittn", "");
Statement stmt = con.createStatement();
for (boolean rsfound = stmt.execute
("select now(); select now();");
rsfound || stmt.getUpdateCount() != -1;
rsfound = stmt.getMoreResults())
{
ResultSet rs = stmt.getResultSet();
while (rs.next())
System.out.println
(rs.getTimestamp(1));
rs.close();
}
stmt.close();
con.close();
}
}
When I run that, I see that it behaves as you say.
-Kevin
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2011-03-31 23:15:45 | Re: JDBC gripe list (the autocommit subthread) |
Previous Message | Oliver Jowett | 2011-03-31 22:32:42 | Re: JDBC gripe list (the autocommit subthread) |