This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes JNDI lookup in standalone jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JNDI lookup in standalone jar file" Watch "JNDI lookup in standalone jar file" New topic

JNDI lookup in standalone jar file

paresh doshi
Ranch Hand

Joined: Nov 20, 2006
Posts: 81

I have a standalone jar file which makes a DB connection. Can i use JNDI lookup for connection as we do in web applications ?

If we can use can anyone provide the sample code. Also provide information on how to setup the jndi name.

Thanks in Advance

Thanks.<br />Paresh Doshi<br />SCJP 1.4
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3740

If the DataSource is setup as a resource (in the app or on the server) then yes.

[OCA 8 Book] [Blog]
I agree. Here's the link:
subject: JNDI lookup in standalone jar file
It's not a secret anymore!