aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Use of JNDI in Standalone java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Use of JNDI in Standalone java program" Watch "Use of JNDI in Standalone java program" New topic
Author

Use of JNDI in Standalone java program

siddharth das
Ranch Hand

Joined: Aug 17, 2007
Posts: 124
Hi,

I have code snippet



But it is showing below error

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
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.bind(Unknown Source)
at TestJDBCOracleDS2.main(TestJDBCOracleDS2.java:29)

The error comes at line ctx.bind("jdbc/dsName",ods);


The above code is in a standalone java program , no web application.

Can you please help.

Is it possibel to use JNDI in standalone java program

Thanks in Advance!!
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Why do you want to use JNDI in Java SE application? It is not available.

I can give you an example of obtaining a connection for in-memory H2 database:


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use of JNDI in Standalone java program