By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

Binding to JNDI datasource - please help

P: n/a
Hi all, I'm relatively new to JNDI concepts and need some help. I am
writing a web app that accepts a variable specifying a jndi pooled
connection datasource as a url variable. This is a requirement and
cannot be changed. For example index.jsp?db=java:defaultdb

How do I use this JNDI name to create a connection? All the
literature I have read says to bind the resource manager connection
factory reference (res-ref-name) to the (jndi-name) in the server
specific xml (assumes knowledge of jndi name beforehand). Then do a
lookup on res-ref-name. In this case I do not know on what server
this war will be deployed and want to bind directly to the datasource
defined by my url variable. Can I do this without using a
res-ref-name and doing a lookup?

Your help is apprecitated,

John
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
John Chambers wrote:
Hi all, I'm relatively new to JNDI concepts and need some help. I am
writing a web app that accepts a variable specifying a jndi pooled
connection datasource as a url variable. This is a requirement and
cannot be changed. For example index.jsp?db=java:defaultdb

How do I use this JNDI name to create a connection? All the
literature I have read says to bind the resource manager connection
factory reference (res-ref-name) to the (jndi-name) in the server
specific xml (assumes knowledge of jndi name beforehand). Then do a
lookup on res-ref-name. In this case I do not know on what server
this war will be deployed and want to bind directly to the datasource
defined by my url variable. Can I do this without using a
res-ref-name and doing a lookup?


Yes. The res-ref-name and friends are there to allow the application
developer to use a specific (logical) JNDI location without knowing the
actual JNDI location. Then the application deployer binds the logical
JNDI location to a physical JNDI location.

But nothing prevents you from accessing the physical JNDI location
directly, except for following good programming practices. ;-)

Just give it a try and see what happens.

HTH,
Ray

--
XML is the programmer's duct tape.
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.