// For this to work you will need to create the
// directories /JNDI/JDBC on your file system first
Context ctx = null;
try {
Properties prop = new Properties();
prop.setProperty(
Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
prop.setProperty(
Context.PROVIDER_URL,
"file:/JNDI/JDBC");
ctx = new InitialContext(prop);
}
catch (NamingException ne) {
System.err.println(ne.getMessage());
}
OracleDataSource ds = new OracleDataSource();
ds.setDriverType("thin");
ds.setServerName("dssw2k01");
ds.setPortNumber(1521);
ds.setDatabaseName("orcl");
ds.setUser("scott");
ds.setPassword("tiger");
ctx.bind("joe", ds);