skip to main content
Configuring Hybrid Data Pipeline for JDBC : Using connection pooling : Using a DataDirect connection pool : Creating a Driver DataSource object

Try Now
Creating a Driver DataSource object
The following Java code example creates a Hybrid Data Pipeline Driver for JDBC DataSource object and registers it with a JNDI naming service.
Note: The DataSource class implements the ConnectionPoolDataSource interface for pooling in addition to the DataSource interface for non-pooling.
// This code creates a Hybrid Data Pipeline Driver for JDBC data source and
// registers it to a JNDI naming service.
// This data source registers its name as <jdbc/HybridSparky>.
// 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:
// Make sure that the fscontext.jar and providerutil.jar files from the
// download are on your classpath.

// From Hybrid Data Pipeline Driver for JDBC:

import com.ddtek.jdbcx.ddhybrid.DDHybridDataSource;
import javax.sql.*;
import java.sql.*;
import javax.naming.*;
import java.util.Hashtable;

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
      DDHybridDataSource ds = new DDHybridDataSource();

      ds.setDescription("Hybrid Data Pipeline on Sparky - Data Source");

      // Set up environment for creating initial context
      Hashtable env = new Hashtable();
      env.put(Context.PROVIDER_URL, "file:c:\\JDBCDataSource");
      Context ctx = new InitialContext(env);

      // Register the data source to JNDI naming service
      ctx.bind("jdbc/HybridSparky", ds);
} catch (Exception e) {
   } // Main
   // class DDHybridDataSourceRegisterJNDI