WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.jdbc.pool.dynamic

This example illustrates how to dynamically create and delete a connection pool in an application using the WebLogic management API.

See:
          Description

Class Summary
Client  
DynamicConnectionPoolHelper This class demonstrates dymamic creation, using and deletion of Connection Pools via Weblogic management API.
 

Package examples.jdbc.pool.dynamic Description

This example illustrates how to dynamically create and delete a connection pool in an application using the WebLogic management API. It creates a JDBC connection pool named dynamicDemoPool. If the connection pool already exists (from previously running this example), the application deletes the existing connection pool and creates a new connection pool with the same name. The examples.jdbc.datasource.dynamic example uses the connection pool created in this example to demonstrate how to dynamically create a DataSource and then how to use it to get and close a database connection.

The example code in DynamicConnectionPoolHelper.java shows how to:

 
Additional Resources for examples.jdbc.pool.dynamic
build.xml The Java Ant build script, which assembles and deploys required client applications for this example.

NOTE: The examples.jdbc.datasource.dynamic example relies on the source files used in this example. If you modify the source files in this example, the examples.jdbc.datasource.dynamic example may not run.

 

The following sections describe how to build and run the example.

  1. Prerequisites
  2. Build the Example
  3. Configure the Server
  4. Run the Example
  5. Check the Output

 

Prerequisites

Before you run this example, you need:

NOTE: This example uses the demo database as shipped with WebLogic Server 7.0. It uses examples as the username and password to connect to the database. If you modify the database, you may need to change the username and password hard-coded in the build.xml file.

 

Build the Example

To build the example, follow these steps:
  1. Open a command shell.
  2. Set up the command shell as described in Setting up Your Environment.
  3. Change to the %SAMPLES_HOME%\server\src\examples\jdbc\pool\dynamic directory.
  4. Execute the following command:
      ant
You should see the following results:
Buildfile: build.xml

compile:
     [echo] Compiling Dynamic Connection Pool Example
    [javac] Compiling 2 source files to D:\bea\weblogic700\samples\server\stage\examples\clientclasses

all:

BUILD SUCCESSFUL

Total time: 3 seconds

 

Configure the Server

  1. Open a new command shell.
  2. Start the server with the examples configuration.
No other server configuration is required. You may want to open the Administration Console to see the new connection pool is represented.

 

Run the Example

You can modify run target in build.xml to fit your environment and server configuration.

 

Check the Output

When you run the example, you should see output in the command shell similar to the following:

D:\bea\weblogic700\samples\server\src\examples\jdbc\pool\dynamic>ant run
Buildfile: build.xml

run:
     [java] Creating Connection Pool...
     [java] Looping through all connection pools...
     [java] oraclePool
     [java] demoPool
     [java] mssqlserverPool
     [java] demoXAPool
     [java] Creating Connection Pool: dynamicDemoPool
     [java] Starting up connection pool.

BUILD SUCCESSFUL

Total time: 5 seconds

 

See Also

Read more about:


Documentation is available at
http://e-docs.bea.com/wls/docs70

Copyright © 2002 BEA Systems, Inc. All Rights Reserved.