Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access DataSource in Java Files

 
Gaurav Kshatriya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to know when we configure a datasource in websphere. How do we actually access this datasource in our java code. Please Help....

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34378
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By looking it up from the JNDI if your code is called by a servlet/ejb. If not, you would have to use an application client.
 
Gaurav Kshatriya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne

Thank you for the help. Actually i am working on a servlet based application. Its a huge application so there are a lot of files. I have tried a lot but i was not able to get from where it looks up the for the datasource configured in Websphere. I will try to debug according to your advice. Any more pointers will be helpful.
 
Deepak Pant
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can look in web.xml file for any JDBC resource references. Then use a text editor like Notepad++ to findout usage of resource reference in your Java files.
 
Gaurav Kshatriya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Pant wrote:You can look in web.xml file for any JDBC resource references. Then use a text editor like Notepad++ to findout usage of resource reference in your Java files.


Hi Deepak

Thanks for the information. I tried diggin in web.xml. What i understood is like, i found out a servlet in web.xml. In that servlet JNDI lookup is performed. Is this rite ??

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic