Sun GlassFish Enterprise Server 2.1 Administration Guide

Creating a JDBC Connection Pool

You can use the Admin Console for creating the JDBC connection pool.

ProcedureCreating a JDBC Connection Pool and JDBC Resource Using the Admin Console

  1. Copy the JDBC driver for database connectivity to as-install/domains/domain_name/lib/ext. Alternatively, add the path to the JDBC driver to classpath-prefix and restart the server.

  2. In the Admin Console, click Create JDBC Connection Pool in the Common Tasks page.

  3. Provide a name for the connection pool, select the resource type, select the database vendor. Click Next.

  4. The Admin Console lists the default pool settings and the properties of datasource class provided by the vendor.

  5. Click the Ping button to test the JDBC connection pool.

  6. In the left-hand pane of the Admin Console, click Resources > JDBC Resources.

  7. Click New.

  8. In the New JDBC Resource page, provide the JNDI name for the resource and the JDBC comnnection pool with which the JDBC resource needs to be associated.

  9. Click OK.

ProcedureCreating a JDBC Connection Pool and JDBC Resource Using the CLI

  1. Use the asadmin create-jdbc-connection-pool command to create a JDBC connection pool.

    Sample command to create a JDBC connection pool:

    asadmin create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property user=dbuser:password=dbpassword:url="jdbc:oracle\:thin\:@localhost\:1521\:ORCL" myjdbc_oracle-pool

  2. Use the asadmin create-jdbc-resource command to create a JDBC resource assicated with this connection pool.

    Sample command to create a JDBC resource:

    asadmin create-jdbc-connection-pool --connectionpoolid myjdbc_oracle-pool jdbc/oracle-resource

  3. Test the connection settings are correct by pinging the connection pool using the asadmin ping-connection-pool command.

    asadmin ping-connection-pool myjdbc_oracle-pool

  4. To edit JDBC connection pool properties, use the asadmin list, get, and set commands.

    Sample list command to list a JDBC connection pool:

    asadmin list myjdbc_oracle-pool

    The sample output of this command:

    domain.resources.jdbc-connection-pool.oracle-pool

    Sample get command to list all properties of a JDBC connection pool:

    asadmin list myjdbc_oracle-pool

    Sample get command to get all properties of a JDBC connection pool:

    asadmin get domain.resources.jdbc-connection-pool.myjdbc_oracle-pool

    Sample get command to set a properties of a JDBC connection pool:

    asadmin set domain.resources.jdbc-connection-pool.myjdbc_oracle-pool.steady-pool-size=20