FileDocCategorySizeDatePackage
TestDSLookUp.javaAPI DocExample986Tue Nov 21 11:05:00 GMT 2000None

TestDSLookUp

public class TestDSLookUp extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


  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());
  }

  DataSource ds = (DataSource)ctx.lookup("joe");
  Connection conn = ds.getConnection();
  Statement  stmt = conn.createStatement();
  ResultSet  rset = stmt.executeQuery(
   "select 'Hello Thin driver data source tester '||" + 
    "initcap(USER)||'!' result from dual");
  if (rset.next())
   System.out.println(rset.getString(1));
  rset.close();
  stmt.close();
  conn.close();