From: Dave Cramer <pg@fastcrypt.com>
To: Rodrigo Willian Bonatto <bonatto@diuno.com.br>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PGJDBC 8 transaction problem
Date: Mon, 5 Jun 2006 09:14:32 -0400
Message-ID: <0E2319EA-BC6B-47DF-AD79-6C7B16495868@fastcrypt.com> (raw)
In-Reply-To: <54CC7CADE26E884EB2BCEC863F5C1F7001012FEC@moscou.diuno.net>
References: <54CC7CADE26E884EB2BCEC863F5C1F7001012FEC@moscou.diuno.net>
Rodrigo,
You don't need the begin, and end
you use connection.commit() instead
Dave
On 5-Jun-06, at 9:01 AM, Rodrigo Willian Bonatto wrote:
> Hi,
>
>
>
> I have a problem using transactions with PGJDBC 8.0 or greater.
>
>
>
> For example:
>
>
>
> In the database I have the following record in the “employee” table:
>
>
>
> name age
>
> John 27
>
>
>
> If I use the PGJDBC 7.4 to update and list the same record in a
> single statement like this:
>
>
>
> Class.forName("org.postgresql.Driver");
>
> Connection conn = DriverManager.getConnection(url, "postgres",
> "postgres");
>
> conn.setAutoCommit(false);
>
> Statement stmt = conn.createStatement();
>
> StringBuffer query = new StringBuffer();
>
> query.append("BEGIN;");
>
> query.append("update employee set age = 28 where age = 27;");
>
> query.append("COMMIT;");
>
> query.append("select name from employee where age = 28");
>
> ResultSet rs = stmt.executeQuery(query.toString());
>
>
>
> Here the resultset will return “John”, but if I use PGJDBC driver
> version 8 or greater, the statement return any result.
>
>
>
> Any ideas?
>
>
>
> Thanks in advanced!
>
>
>
> Rodrigo
>
>
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pg@fastcrypt.com, bonatto@diuno.com.br
Subject: Re: PGJDBC 8 transaction problem
In-Reply-To: <0E2319EA-BC6B-47DF-AD79-6C7B16495868@fastcrypt.com>
References: <54CC7CADE26E884EB2BCEC863F5C1F7001012FEC@moscou.diuno.net> <0E2319EA-BC6B-47DF-AD79-6C7B16495868@fastcrypt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox