File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI and Database Connectivity in Stand-alone Application

 
Deepak Kumar Jena
Ranch Hand
Posts: 68
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In web application, we can connect to the database by supplying the configuration details in server.xml or context.xml. Is it possible to achive the same thing in a stand-alone application? I am getting the below exception while running an stand-alone application:
Cannot get connection: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

From the description it is clear that the configutarion detail need to be provided in the form of environment or system property or through the application resource file java.naming.factory.initial. Tried to get the solution in the web, but didn't got the result.
Kindly sugest.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33671
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak,
IN an "application client" project you can access a server's JNDI under certain circumstances. This isn't usually a standalone application though.

For a standalone application, it would be better to user your own datasource without JNDI.
 
Deepak Kumar Jena
Ranch Hand
Posts: 68
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne for making me know about another interesting feature of JDBC. If I am not wrong, I have to use Tomcat DBCP feature (by using the jars - commons-pool-x.x.x.jar and commons-dbcp-x.x.jar and getting an instance of the class BasicDataSource) for this purpose.

But still I am hunting for the answer with the JNDI setup.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic