Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

register data source in JNDI

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic