Re: PGJDBC 8 transaction problem

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Rodrigo Willian Bonatto <bonatto(at)diuno(dot)com(dot)br>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: PGJDBC 8 transaction problem
Date: 2006-06-05 13:14:32
Message-ID: 0E2319EA-BC6B-47DF-AD79-6C7B16495868@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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
>
>
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2006-06-05 13:25:06 Re: PGJDBC 8 transaction problem
Previous Message Rodrigo Willian Bonatto 2006-06-05 13:01:40 PGJDBC 8 transaction problem