problem with InitialContext's lookup method
622094Feb 7 2008 — edited Feb 13 2011Hi, I'm using Sun Java System App Server 9, I created a JDBC resource called jdbc/mdr_desarrollo and it is related to a connection pool that uses Oracle Data Source.
I created a Test class to test the connections. This is part of the code:
public static void main(String [] args){
try {
InitialContext ctx = new InitialContext();
OracleDataSource ods =
(OracleDataSource) ctx.lookup("java:comp/env/jdbc/mdr_desarrollo");
Connection conn = ods.getConnection();
System.out.println("Successful connection!!");
But when I run it, I see the exception:
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
This code is very similar to the shown in the article
http://www.oracle.com/technology/sample_code/tech/java/oc4j/htdocs/jndi/TestConnection.java.txt
I'm not using Oracle A. S. but I don't think that the Sun Server is very different.
What should I do to make that this work?