This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Using datasource in netbeans to get connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Using datasource in netbeans to get connection" Watch "Using datasource in netbeans to get connection" New topic
Author

Using datasource in netbeans to get connection

chinomso ikwuagwu
Greenhorn

Joined: Mar 28, 2006
Posts: 11
The method initialContext.lookup("java:comp/env/myDatabase");

generated the following exception

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(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at enterprise.Test2.getMyDatabase2(Test2.java:54)
at enterprise.Test2.doTest(Test2.java:36)
at enterprise.Test2.main(Test2.java:46)

How do i resolve this?
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Which database system are you trying to connect too?
chinomso ikwuagwu
Greenhorn

Joined: Mar 28, 2006
Posts: 11
MySQL
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Have you properly set up the client libraries?
Reza Rahman
author
Ranch Hand

Joined: Feb 01, 2005
Posts: 580
    
    5
Chinomso,

You are missing the jndi.properties file in your classpath. Here is some material that might help: http://www.informit.com/articles/article.aspx?p=384904.

Regards,
Reza


Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
chinomso ikwuagwu
Greenhorn

Joined: Mar 28, 2006
Posts: 11
Thanks, just what i needed
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using datasource in netbeans to get connection
 
Similar Threads
Compiling two public scope java classes in a .java file
Implementing an Interface Down the Inheritance Tree Question
Running the headfirst ejb 1st chapter - problem running
does static methods inherit ? what about private ?
help moderator or site admin