Re: JTA / JDBC support

From: "Freddy Villalba Arias" <fvillalba(at)madrid(dot)bilbomatica(dot)es>
To: "Oliver Jowett" <oliver(at)opencloud(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JTA / JDBC support
Date: 2004-04-06 06:30:31
Message-ID: 6ED57DF76179F640AD3820FE29E0A00D1D184A@bmsrv001.madrid.bilbomatica.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi Oliver,

Your answer has been quite helpful. I really appreciate it.

Anyway, I'm giving you the (bit more) concrete situation, hoping you can
shed some more light on it...

First of all, the web app we'll be implementing will run on a JBoss app
server (+ Tomcat). AFAIK (based on JTA's specs), the TM (and, for what
it matters, all JTA objects') implementations will be provided by JBoss
(/Tomcat), whom should make them accessible through JNDI's lookup method
(Am I right here?????).

Second, I'm not actually interested in distributed transactions, but
only the TM's main features; that is, the ability to control - in a
standard, centralized way - all JDBC operations taking place on that
single JVM. I'm implementing a web app that has lots of tables and
requires most operations to be transactional. All operations access the
one and only DB there will be. Then, as I understood it, I won't be
needing (using) the XA objects. Hence, In a few words, what I'd want to
know (confirm) is: on a "PostgreSQL environment", I can trust the TM to
manage a typical transaction for me, as stated in the example below?

...

String utxPropVal = System.getProperty("jta.UserTransaction");
Context ctx = new InitialContext();

// Get a new transaction
UserTransaction utx = (UserTransaction) ctx.lookup(utxPropVal);

try {

utx.begin();
// The "rn" object represents a parametrized business rule
rn.execute(); // This executes the business rule's (ultimately,
JDBC statements)
utx.commit();

} catch (BusinessRuleException bre) {

...

utx.rollback();

...

}

...

Thanks in advance,
Freddy.

-----Mensaje original-----
De: Oliver Jowett [mailto:oliver(at)opencloud(dot)com]
Enviado el: lunes, 05 de abril de 2004 23:49
Para: Freddy Villalba Arias
CC: pgsql-jdbc(at)postgresql(dot)org
Asunto: Re: [JDBC] JTA / JDBC support

Freddy Villalba Arias wrote:
> Hi!
>
> Are there any drivers (for PostgreSQL v7.4.2) that support JTA?
>
> I'm interested in using JDBC 2.0, but I encourage you (and would
greatly
> appreciate it) to give me as much information as you can about JTA /
> JDBC (different versions) support...

Short answer: the standard postgresql driver doesn't support XAResource,

and it doesn't make sense to support it.

Long answer:

JTA defines XAResource as the interface between the Transaction Manager
(TM) and Resource Manager (RM -- in this case the JDBC driver) for
resources that can participate in two-phase commit of global
transactions. While there's support for a one-phase optimization, that's

an option on the part of the TM, not the RM. There's no specification in

JTA of the interface between the TM and RM for local or one-phase
transactions AFAIK.

As the PostgreSQL backend itself (let alone the driver) doesn't support
two-phase commit or global transactions, it doesn't really make sense
for the driver to implement XAResource. It could implement it and then
refuse all requests to prepare transactions or switch transaction
context, but I don't know how useful that would be since it depends so
much on the TM's behaviour.

But I'd be surprised if your TM of choice did not support enlistment of
one-phase JDBC resources directly (with a bit of help from the app
server, which has to actually do the enlistment at the right point)
using the normal commit/rollback JDBC interface to talk to the driver.

-O

Browse pgsql-jdbc by date

  From Date Subject
Next Message Freddy Villalba Arias 2004-04-06 08:46:19 Visual tools
Previous Message Tom Lane 2004-04-06 05:41:01 Re: slow delivery of pgsql-jdbc mail?