Using the Database Binding Component

Setting Up Database Access

Follow these steps:

  1. Make the driver's JAR file accessible to the domain's server instance. See To Integrate a JDBC Driver.

  2. Create a connection pool for the database. See To Create a JDBC Connection Pool.

  3. Create a JDBC resource that points to the connection pool. See To Create a JDBC Resource.

Integrating a JDBC Driver

A JDBC driver translates an application's JDBC calls into the protocol of the database server.

To integrate the JDBC driver into an administrative domain, perform either of the following:

ProcedureTo Integrate a JDBC Driver

  1. Make the driver accessible to the common class loader.

    1. Copy the driver's JAR and ZIP files into the domain-dir/lib directory or copy its class files into the domain-dir/lib/ext directory.

    2. Restart the domain.

  2. Make the driver accessible to the system class loader.

Creating a JDBC Connection Pool

When creating the pool with the Admin Console, you are actually defining the aspects of a connection to a specific database. A JDBC connection pool is a group of reusable connections for a particular database. Because creating each new physical connection is time consuming, the server maintains a pool of available connections to increase performance. When an application requests a connection, it obtains one from the pool. When an application closes a connection, the connection is returned to the pool.

Before creating the pool, you must first install and integrate the JDBC driver. See To Integrate a JDBC Driver.

When creating the Create Connection Pools, certain data specific to the JDBC driver and the database vendor must be specified. Before proceeding, gather the following information:

ProcedureTo Create a JDBC Connection Pool

  1. Select the Common Tasks node, then click Resources —> JDBC —> Connection Pool.


    Note –

    Select New to create a new connection pool from the New Connection Pool page.


  2. Specify the General Settings as follows:

    1. Name: Specify a Name for the pool.

      For example, mysqlpool

    2. Resource Type: Select a Resource Type from the drop-down menu.

      Choices include,

      • javax.sql.XADataSource (global transactions)

      • java.sql.ConnectionPoolDataSource (local transactions, possible performance improvements)

      • javax.sql.DataSource (local transactions only)

    3. Database Vendor: Select a vendor from the list provided in the drop-down menu.

      For example, mySQL

    New JDBC Connection
  3. Click Next.

  4. Specify the additional General Settings as follows:

    • Datasource Classname: If the JDBC driver has a Datasource class for the resource type and database vendor specified in the previous page, then the value of the Datasource Classname field is provided.

      For example, MySQL : com.mysql.jdbc.jdbc2.optional.MysqlDataSource

    • Description: A text description of the connection pool.

    New JDBC General
  5. Specify the Pool Settings.

    The values are entered, by default.

  6. Specify the Connection Validation.

    The values are entered, by default.

  7. Specify the Transaction Isolation settings.

    The values are entered, by default.

  8. Add the required properties in the Additional Properties table, such as database name (URL), user name, and password. Enter the following.

    1. databaseName

    2. password

    3. portNumber

    4. serverName

    5. user

    New JDBC Additional
  9. Click Finish.

ProcedureTo Create a JDBC Resource

Applications get a database connection from a connection pool by looking up a data source on the Java Naming and Directory Interface (JNDI) tree and then request a connection. The connection pool associated with the datasource provides the connection to the application.

Before You Begin

Before creating a JDBC resource, first create a JDBC connection pool. See To Create a JDBC Connection Pool.

  1. Expand the Resources, then JDBC path node.

  2. Select the JDBC Resources node.

  3. Click New from the JDBC Resources page.

  4. Specify the Resource settings as follows:

    1. JNDI Name: Specify a unique name. The JNDI name organizes and locates components within a distributed computing environment similarly to the way that card catalogs organize and represent locations of books in a library. Consequently, the JNDI name becomes an important method of accessing the JDBC resource. By convention, the name begins with the jdbc/string.

      For example: jdbc/payrolldb.


      Note –

      Remember to give a forward slash.


    2. Pool Name: Choose the connection pool to be associated with the new JDBC resource.

    3. Description: Type a short description of the resource.

    4. Status: If you want the resource to be unavailable, deselect the Enabled checkbox. By default, the resource is available (enabled) as soon as it is created.

  5. Click OK.

    New JDBC Resource