Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 693549FB73C for ; Tue, 20 Feb 2007 06:51:17 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 62146-06 for ; Tue, 20 Feb 2007 06:51:04 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.236]) by postgresql.org (Postfix) with ESMTP id E756A9FB75A for ; Tue, 20 Feb 2007 06:51:13 -0400 (AST) Received: by nz-out-0506.google.com with SMTP id i11so2201855nzh for ; Tue, 20 Feb 2007 02:51:12 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=tCwrCIDz8FoN5SREiiXGGg+bASMMTsV1pmh1Vxx96ysPQ2nEWOzrDS5imQ4QQAcYHUDL26aS5BfYgtWGjq34j9agjcE/WNmhtwMtSAmQ0EfX0vtJq4ZkRKYTqdDIicJmpb+Kldd9Mf0EI/yx/iIM4rAVAi5Ar9TXE9GysObk6/o= Received: by 10.64.185.7 with SMTP id i7mr11505170qbf.1171968672789; Tue, 20 Feb 2007 02:51:12 -0800 (PST) Received: from ?172.24.32.30? ( [62.232.55.118]) by mx.google.com with ESMTP id e11sm4861037qbc.2007.02.20.02.51.10; Tue, 20 Feb 2007 02:51:11 -0800 (PST) Message-ID: <45DAD28A.2010907@enterprisedb.com> Date: Tue, 20 Feb 2007 10:50:50 +0000 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.8 (X11/20061116) MIME-Version: 1.0 To: James Im CC: pgsql-jdbc@postgresql.org Subject: Re: how to continue using a connection after an error with autocommit=false References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/104 X-Sequence-Number: 16660 James Im wrote: > I just find out that I cannot continue using a connection when I use > autocommit=false and that an sql insert failed. That's intended behavior in PostgreSQL. I just wrote this in another thread last week: If you have a statement in your transaction that you know might fail, you can use savepoints to avoid having to restart the whole transaction: Savepoint sp = conn.setSavepoint(); try { stmt.executeQuery("SELECT 1 FROM table_that_might_not_exist"); } catch(SQLException ex) { sp.rollback(sp); } stmt.executeQuery("SELECT * FROM table_that_exists"); ... -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com