Re: Postgres JDBC, WS and commit

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: mephysto <mephystoonhell(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Postgres JDBC, WS and commit
Date: 2012-05-21 08:21:41
Message-ID: 4FB9FB15.3000406@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mikko Tiihonen 2012-05-21 16:57:05 Re: json type
Previous Message Craig Ringer 2012-05-21 08:18:17 Re: Patch: Add support for hstore extension - and map it to/from java.util.Map