• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does resource-ref do for you?

 
Mark Williams
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Abhijit Rai
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • 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

http://www.coderanch.com/forums/posts/watch/0/159428
 
Mark Williams
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • 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 ).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic