users@glassfish.java.net

Re: What is the official GlassFish position on which kind of DataSources to use?

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Thu, 11 Oct 2012 14:45:57 -0700

Laird Nelson wrote:
> On Wed, Oct 10, 2012 at 11:22 AM, Laird Nelson <ljnelson_at_gmail.com
> <mailto:ljnelson_at_gmail.com>> wrote:
>
> When setting up a connection pool, I can (if my driver supports
> it) choose to expose the connections as javax.sql.DataSources,
> javax.sql.ConnectionPoolDataSources or javax.sql.XADataSource.
>
> After uncovering a state of affairs on the larger web that can
> best be described as pure abject confusion punctuated here and
> there by misguided folklore, I realized that no one really has the
> answer, and that it is going to be an application-server-dependent
> issue, whether it was defined as such or not.
>
>
> My (still unanswered) StackOverflow
> question: http://stackoverflow.com/questions/12826191/in-an-application-server-environment-should-one-prefer-javax-sql-datasource-or
>
> It /seems/ that one should always use ConnectionPoolDataSource (or
> XADataSource) when one's driver supports it.

I can answer the XA vs. non-XA part: non-XA resource commit is faster,
and if it's a single non-XA resource in a transaction, GF doesn't even
start the XA parts. But (of course) you can have only 1 non-XA resource
in a transaction, and if you have 2 resources, and the resource or the
server crashes (and tx recovery on startup is enabled) the non-XA
resource cannot be recovered.

-marina

> It /seems/ like at the data-source-setup stage one should not
> deliberately expose one's data source (little-d, little-s) as a
> javax.sql.DataSource if one has an alternative. Is that correct?
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>