wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes JNDI and Database Connectivity in Stand-alone Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI and Database Connectivity in Stand-alone Application" Watch "JNDI and Database Connectivity in Stand-alone Application" New topic
Author

JNDI and Database Connectivity in Stand-alone Application

Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

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.

dkj4jdk
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29237
    
139

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI and Database Connectivity in Stand-alone Application
 
Similar Threads
Why JVM can't find my jdbc
how to use jpa & database connection pool in swing?
Servlet communication
Install shield for swing application?
Dialect class not found