Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 98A6EA684DD for ; Mon, 21 May 2012 05:22:02 -0300 (ADT) Received: from mail-pz0-f46.google.com ([209.85.210.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SWNsO-0001ke-Ew for pgsql-jdbc@postgresql.org; Mon, 21 May 2012 08:22:01 +0000 Received: by dady13 with SMTP id y13so6496663dad.19 for ; Mon, 21 May 2012 01:21:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=Y/oZrizWspK0w3sEZa/5XqvqTYm4HrmrEyemfJJT8M0=; b=Yjmp0sM0+IKfTIV46lU8dCMTtempKN+EqGQ+JmWs+kWLTvYEwdgT4+cV9SPn3yK3PT GH5mVs9CHWcX1lq8BsiSY3qHcCWQDdhD/g6IsyooFB99kEoc6IbFwUnvjdmB4wSNYbeB ZUNnSjCs2MT8j1PXnIZDgTr/dQvogbaVdeTZf/01zSSOm7tTeTklfq4x6X8b4uMKYAku HBi0RgkwgJBRFE8KWGxsp38zAWx0kZc5tBjLCsAhVqPMXC5u02/iUJLY2sEpa3fbAQA6 JiwJ0LBvhZx0WaRU7w55G7PeMqxq+nkgO1wKk0SD7OMvLCim4pgH5ZVpFFU15rJ8mvGj /jBw== Received: by 10.68.221.72 with SMTP id qc8mr66395664pbc.63.1337588506687; Mon, 21 May 2012 01:21:46 -0700 (PDT) Received: from wallace.localnet (office1.postnewspapers.com.au. [150.101.171.128]) by mx.google.com with ESMTPS id pg6sm22361454pbb.41.2012.05.21.01.21.43 (version=SSLv3 cipher=OTHER); Mon, 21 May 2012 01:21:45 -0700 (PDT) Message-ID: <4FB9FB15.3000406@ringerc.id.au> Date: Mon, 21 May 2012 16:21:41 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: mephysto CC: pgsql-jdbc@postgresql.org Subject: Re: Postgres JDBC, WS and commit References: <1336576000350-5697657.post@n5.nabble.com> In-Reply-To: <1336576000350-5697657.post@n5.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmwk6IEdjG+fGDuaWMG/TAlapdovbm3FJkWKTKZmZXgS3CJRG+I507RfxmNr9JKxTlkck/p X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/67 X-Sequence-Number: 22967 On 05/09/2012 11:06 PM, mephysto wrote: > Hi there, > I'm using postgres-JDBC ina GlassFish application server to develop a web > service application. I made several tries with either XA and standard > driver. I use JDBC connection pool of GlassFish. > I found that transaction started into a web service operation, are closed at > the end of operation, not when in the code the connection are closed. > > I am searching a solution to close transaction that permit me to close > trasaction when I want it, before end of web service operation. > > Is there a way to achieve this goal? If you're using XA transactions in a Java EE context, what you want is probably an EJB3 with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) which will force the EJB business method(s) so annotated to run in their own independent transactions. Note that these transactions will *NOT* be able to see any uncommitted changes from your main transaction, they're completely independent and behind the scenes with PostgreSQL are actually new connections to the server. -- Craig Ringer