FileDocCategorySizeDatePackage
TestDSBind.javaAPI DocExample961Tue Nov 21 11:04:32 GMT 2000None

TestDSBind.java

import java.sql.*;
import java.util.*;
import javax.naming.*;
import oracle.jdbc.pool.*;

public class TestDSBind {

 public static void main (String args [])
  throws SQLException, NamingException {
  
  // 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);
 }
}