//************************************************************************
// This code creates a Progress DataDirect for JDBC data source and
// registers it to a JNDI naming service. This JDBC data source uses the
// DataSource implementation provided by DataDirect Connect Series
// for JDBC Drivers.
//
// This data source registers its name as <jdbc/ConnectOracle>.
//// NOTE: To connect using a data source, the driver needs to access a JNDI data
// store to persist the data source information. To download the JNDI File
// System Service Provider, go to:
//
// http://www.oracle.com/technetwork/java/javasebusiness/downloads/
// java-archive-downloads-java-plat-419418.html#7110-jndi-1.2.1-oth-JPR
////
// Make sure that the fscontext.jar and providerutil.jar files from the
// download are on your classpath.
//************************************************************************
// From DataDirect Connect Series for JDBC:
import java.util.Hashtable;
import com.ddtek.jdbcx.oracle.OracleDataSource;
public class OracleDataSourceRegisterJNDI {
public static void main(String argv[]) {
try {
// Set up data source reference data for naming context:
// ----------------------------------------------------
// Create a class instance that implements the interface
// ConnectionPoolDataSource
OracleDataSource ds = new OracleDataSource();
ds.setDescription("Oracle DataSource");
ds.setServerName("Server3");
ds.setPortNumber(1521);
ds.setUser("User123");
ds.setPassword("secret");
ds.setSID("ORCL");
// Set up environment for creating initial context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:C:\\JNDI_Test_Dir");
Context ctx = new InitialContext(env);
// Register the data source to JNDI naming service
ctx.bind("jdbc/ConnectOracle", ds);
} catch (Exception e) {
System.out.println(e.getStackTrace());
e.printStackTrace();
return;
}
}// Main
}
// class OracleDataSourceRegisterJNDI