Sun Java System Web Server 7.0 Developer's Guide to Java Web Applications

Database Connection Pooling

Database connection pooling enhances the performance of servlet or JSP database interactions. For more information about the JavaTM DataBase Connectivity (JDBCTM) software, see Configuring JDBC Resources in Sun Java System Web Server 7.0 Administrator’s Guide.

The simplest connection pool can be configured by using the given. In this example, the connection pool is assigned to use the ORACLE JDBC driver.

ProcedureTo Configure a Simple Connection Pool

In this example procedure, the connection pool uses the ORACLE JDBC driver.

  1. Start wadm

    $ ./bin/wadm --user=admin
    Please enter admin-user-password>user-admin-password
    Sun Java System Web Server 7.0 B01/02/2006 14:22
  2. Verify the list of available configurations.

  3. Create the jdbc-resource configuration.

    For more information about all possible elements, see Sun Java System Web Server 7.0 Administrator's Configuration File Reference.

    wadm>create-jdbc-resource --config=test 
    --datasource-class=oracle.jdbc.pool.OracleDataSource jdbc/MyPool
  4. Add properties to jdbc-resource.

    Properties are primarily used to configure the driver's vendor-specific properties. In the following example, the values for the properties url, user, and password are added to jdbc-resource.

    wadm>list-jdbc-resource-userprops --config=test --jndi-name=jdbc/MyPool 
    password=mypassword user=myuser url=jdbcZ:oracle:thin:@hostname:1421MYSID
  5. Enable the connection validation.

    wadm>set-jdbc-resource-prop --config=test --jndi-name=jdbc/MyPool
    connection-validation-table-name=test connection-validation=table
    CLI201 Command "set-jdbc-resource-prop" ran successfully
  6. Change the pool setting.

    In this example, the maximum number of connections is set to 100.

    wadm>set-jdbc-resource-prop --config=test --jndi-name=jdbc/MyPool max-connections=100
    CLI201 Command "set-jdbc-resource-prop" ran successfully.
  7. Deploy the configuration.

    wadm>deploy-config test
    CLI201 Command "deploy-config" ran successfully.

    You can install a JDBC driver with Java Archive (JAR) files in one of the following ways:

    • Copy the driver's JAR file into the server's instance library directory. JAR files in the instance library directory will automatically load and available for server.

    • Modify the JVM class-path- suffix to include JDBC drivers jar file. The new value will overwrite the old value of the element. For example, wadm> set-jvm-prop --config=test class-path-suffix=/export/home/lib/classes12.jar