1. New Empty project in JDeveloper
2. Add the following libraries, which will ensure all the required jars needed are added to the classpath:
- Oracle JDBC
- JSP Runtime
- Apache Ant
package pas.test;
import java.sql.Connection;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
public class AccessDataSource10132
{
public static void main(String[] args)
throws Exception
{
Connection conn = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"oracle.j2ee.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");
env.put(Context.SECURITY_CREDENTIALS, "welcome1");
env.put(Context.PROVIDER_URL,
"opmn:ormi://sracanov-au2.au.oracle.com:6005:OC4J_FCF/default");
InitialContext ic = new InitialContext(env);
DataSource ds = (DataSource) ic.lookup("jdbc/scottDS");
conn = ds.getConnection();
System.out.println("Auto commit is -> " + conn.getAutoCommit());
System.out.println("all done..");
}
}
The output is as follows:
Auto commit is -> true
all done..