Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem with InitialContext's lookup method

622094Feb 7 2008 — edited Feb 13 2011
Hi, 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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 13 2011
Added on Feb 7 2008
4 comments
4,031 views