X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3C5F29FAD5A for ; Mon, 5 Jun 2006 10:19:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 17387-01-2 for ; Mon, 5 Jun 2006 10:19:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id 154EF9FB274 for ; Mon, 5 Jun 2006 10:14:35 -0300 (ADT) Received: (qmail 19780 invoked from network); 5 Jun 2006 13:14:34 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 5 Jun 2006 13:14:34 -0000 In-Reply-To: <54CC7CADE26E884EB2BCEC863F5C1F7001012FEC@moscou.diuno.net> References: <54CC7CADE26E884EB2BCEC863F5C1F7001012FEC@moscou.diuno.net> Mime-Version: 1.0 (Apple Message framework v750) Content-Type: multipart/alternative; boundary=Apple-Mail-32--592619259 Message-Id: <0E2319EA-BC6B-47DF-AD79-6C7B16495868@fastcrypt.com> Cc: From: Dave Cramer Subject: Re: PGJDBC 8 transaction problem Date: Mon, 5 Jun 2006 09:14:32 -0400 To: Rodrigo Willian Bonatto X-Mailer: Apple Mail (2.750) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/16 X-Sequence-Number: 15296 --Apple-Mail-32--592619259 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed 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 =93employee=94 = table: > > > > name age > > John 27 > > > > If I use the PGJDBC 7.4 to update and list the same record in a =20 > single statement like this: > > > > Class.forName("org.postgresql.Driver"); > > Connection conn =3D DriverManager.getConnection(url, "postgres", =20 > "postgres"); > > conn.setAutoCommit(false); > > Statement stmt =3D conn.createStatement(); > > StringBuffer query =3D new StringBuffer(); > > query.append("BEGIN;"); > > query.append("update employee set age =3D 28 where age =3D 27;"); > > query.append("COMMIT;"); > > query.append("select name from employee where age =3D 28"); > > ResultSet rs =3D stmt.executeQuery(query.toString()); > > > > Here the resultset will return =93John=94, but if I use PGJDBC driver =20= > version 8 or greater, the statement return any result. > > > > Any ideas? > > > > Thanks in advanced! > > > > Rodrigo > > > > --Apple-Mail-32--592619259 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=WINDOWS-1252 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,=A0

I have a problem using transactions with PGJDBC = 8.0 or greater.

=A0

For example:

=A0

In the database I have the following record in = the =93employee=94 table:

=A0

name=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = ageJohn=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = 27=A0

If I use the PGJDBC 7.4 to update and list the = same record in a single statement like this:=A0

Connection conn =3D = DriverManager.getConnection(url, "postgres", "postgres");conn.setAutoCommit(false);

Statement stmt =3D = conn.createStatement();

StringBuffer query =3D new = StringBuffer();

query.append("BEGIN;");

query.append("update employee set age =3D 28 = where age =3D 27;");

query.append("COMMIT;");

query.append("select name from employee where = age =3D 28");

ResultSet rs =3D = stmt.executeQuery(query.toString());

=A0

Here the resultset will return =93John=94, but = if I use PGJDBC driver version 8 or greater, the statement return any = result.=A0

Any ideas?

=A0

Thanks in advanced!=A0

Rodrigo

=A0



= --Apple-Mail-32--592619259--