users@glassfish.java.net

Re: Confused aboud create-jdbc-resource: can I use Java EE 6 JNDI namespaces?

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Thu, 26 Jul 2012 14:05:14 -0700

I'll leave the actual answer to our connector people, but did you try a
@DataSourceDefinition with your app?

-marina

Laird Nelson wrote:
> The documentation for creating JDBC resources
> (http://docs.oracle.com/cd/E26576_01/doc.312/e24928/jdbc.htm#ggnda)
> says (in part) this:
>
> Because all JNDI names are in the |java:comp/env| subcontext, when
> specifying the JNDI name of a JDBC resource in the Administration
> Console, use only the |jdbc/|name format.
>
>
> But I would like to create a JDBC resource that I may subsequently
> look up using the following JDBC name (which is to my knowledge Java
> EE 6-compliant, according to section EE.5.2.2, and is /not/ in the
> java:comp/env subcontext but is instead global to the instance):
>
> java:global/jdbc/H2Test
>
>
> If I create this JDBC resource by hand-editing the domain.xml (boo, I
> know), everything works fine:
>
> <jdbc-resource pool-name="H2TestPool"
> jndi-name="${testDatabaseDataSourceName}" />
>
>
> (In this case testDatabaseDataSourceName is a System property that
> resolves to "java:global/jdbc/H2Test", and the referenced connection
> pool has already been created.)
>
> If I create this JDBC resource (or try to) using create-jdbc-resource,
> passing it "java:global/jdbc/H2Test", the command fails saying that
> JNDI names cannot have ":" in them.
>
> But if I do create-jdbc-resource and pass only jdbc/H2Test, then as I
> understand it I'm really creating java:comp/env/jdbc/H2Test.
>
> In case it matters, I'm creating a global data source for use during
> embedded testing.
>
> Any enlightenment greatly appreciated.
>
> Thanks,
> Laird
>
> --
> http://about.me/lairdnelson
>