• Post Reply Bookmark Topic Watch Topic
  • New Topic

register data source in JNDI  RSS feed

 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to creating connection pooling with JDBC. Please explain (1) how to register data source in JNDI (2) how to retrieve that data source to get connection ?
 
Hany Shafik
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to register a data source in JNDI is dependent on the application server that your are using, most application servers have admin interface that user can use to create a data source.
After creating your data source you will have to add in your deployment descriptor (e.g. web.xml or ejb.xml) a resoruce-ref element
for example

It means that your application is dependent on a datasource whose name jdbc/Test
The last step is to lookup your datasource from inside your code
for example

 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hany,

JNDI name/Data Resource/Resource name --> these all are the one and same thing ?

After creating your data source


this means registering data source into JNDI tree ?
 
Hany Shafik
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are only two names resource-ref name and the real datasource name. The JNDI name you use to lookup (resource-ref name) doesn't have to be the same as the one you created in your application server. Most application servers have vendor specific deployment descriptor that you can you use to map your resource-ref name to the real datasource name.
And the answer to your second question is yes.
I hope this clear up this matter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!