• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

What does resource-ref do for you?

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope this is the right forum...

When you set up a JDBC datasource on an application server, at least in my experience, you must give a JNDI name to that datasource. However, in the deployment descriptor for the application we also have the resource-ref entry that references the JNDI name of the datasource. What is the idea behind the resource-ref entry in the deployment descriptor?
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,


When you set up a JDBC datasource on an application server, at least in my experience, you must give a JNDI name to that datasource.


Clarification:
You can access a database with the JDBC API without using JNDI ,but yes when it comes to datasource you have to use some naming service,I too have used JNDI.
As for the question ,
There are many reasons that according to the specification, one should also specify the <resource-ref> in web.xml. One of the most important reasons is the scope of the DataSource being used.

<resource-ref>
. . .
<res-sharing-scope>Shareable</res-sharing-scope>
. . .
</resource-ref>

You can read more about that in the following thread

https://coderanch.com/forums/posts/watch/0/159428
 
Mark Williams
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply... and yes, I do realize that JNDI is not the only way to access your JDBC driver/connection.

So, what I am starting to think is that the resource-ref entry really applies more EJBs are used. I am just using POJOs for my JDBC so I think I will just add it to my web.xml and not think about it too much (unless it breaks ).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic