X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 31C7D9DC837 for ; Thu, 22 Dec 2005 21:37:48 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05577-03 for ; Thu, 22 Dec 2005 21:37:51 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.197]) by postgresql.org (Postfix) with ESMTP id DBCD09DC807 for ; Thu, 22 Dec 2005 21:37:45 -0400 (AST) Received: by zproxy.gmail.com with SMTP id 13so575559nzn for ; Thu, 22 Dec 2005 17:37:50 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=McvswNJyIiob6tuNFExippaVQ6MvMD5efSkwkKp99ravr4ZkWScVteVunsyq41en+VPio+OSYb3id43teL9oYfdAr1oo8Mq6PyIi2vXMCwRFkPldEhnySjpS7ndWWtrBvgkATR/2nwxeDQTjluxAyuP2OwvPL7mNwjtAFsSFS6o= Received: by 10.65.115.20 with SMTP id s20mr620692qbm; Thu, 22 Dec 2005 17:37:49 -0800 (PST) Received: by 10.65.96.4 with HTTP; Thu, 22 Dec 2005 17:37:49 -0800 (PST) Message-ID: <4bd3e1480512221737h2c43739epd1c9640e1d2cea0@mail.gmail.com> Date: Thu, 22 Dec 2005 18:37:49 -0700 From: Assad Jarrahian To: pgsql-jdbc@postgresql.org Subject: problems with currval and rollback MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] X-Spam-Score: 0.08 X-Spam-Level: X-Archive-Number: 200512/114 X-Sequence-Number: 14445 Hi all, So I started to make some changes with my jdbc code here and there (nothing to do with the relevant lines) and suddenly currval and rollback don't work. try{ db.setAutoCommit(false); addLM.setInt(1, lm.getOrigin()); ....... addLM.executeUpdate(); sql =3D db.createStatement(); ResultSet result =3D sql.executeQuery("SELECT currval('lm_id_seq');"); if (result. next()){ db.commit(); db.setAutoCommit(true); else{ db.rollback(); //reverse all changes db.setAutoCommit(true); } catch(SQLException ex){ try { db.rollback(); db.setAutoCommit(true); } catch (SQLException e) { throw e; } throw ex; } What happens is that the it inserts a db, but cannot get a value back using currval (ERROR: ERROR: currval of sequence "lm_id_seq" is not yet defined in this session 55000 ) , yet the db gets the addlm inserted. It should rollback, but it does not. What gives? I ran the insert-currval combo from psql and it worked. What gives? Any help would be appreciated. -assad