This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
This sounds like a good idea, except there's only one problem: To use JNDI, you have to have a server that supports JNDI running or your JNDI lookup will fail. This means you're making your stand-alone java application so that it won't run unless a JNDI server is running. Not such a good idea.
With some good OO-Design, it's not that hard to design a flexible solution. Create an interface for a service that gets a database connection. Then create two different implementations of that interface -- one for JNDI and one for stand-alone Java. In your application code, you'd then code to the interface rather than the implementation. [ March 03, 2007: Message edited by: Merrill Higginson ]