What is the official GlassFish position on which kind of DataSources to use?
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.
GlassFish's own documentation makes no mention of ConnectionPoolDataSource,
but of course it's an option that the admin console lists:
The documentation for javax.sql.ConnectionPoolDataSource does not provide a
hint as to whether it should be preferred or not in an application server
The documentation for javax.sql.DataSource seems to imply, but does not
explicitly state, whether an implementor is pooling its connections
natively or not:
GlassFish then provides me the ability to pick between these two wildly
underspecified interfaces. How do I make the decision about which one to
pick, particularly if (as is common) my driver vendor implements both? Do
I err on the side of saying:
"Hmm, maybe my driver vendor knows best, so I will use (for example)
javax.sql.ConnectionPoolDataSource implemented by
because I have a warm feeling that this will cause my vendor's
implementation of pooling to be used, I think...."
...or do I say:
"Oh, I see from the javax.sql.DataSource documentation, or at least I think
I do, that it is designed to hide whether pooling is happening or not, so I
will use (for example) javax.sql.DataSource implemented by
and rely on the application server to do pooling...hmm...or maybe it will
do some testing inside itself? and figure out if the implementation class
also implements javax.sql.ConnectionPoolDataSource, as is often the case?"
Then, suppose I need XA (which actually I do in some deployments). In that
case, surely--SURELY--I have to use javax.sql.XADataSource as my interface?
Or maybe this is another case where really I should use
javax.sql.DataSource, and then specify an implementation class that
Here is a sample (one of hundreds) question that illustrates the fact that
no one really knows what's going on in this area:
Thanks for any help or guidance here.