WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.jdbc.datasource.dynamic

This example shows how to dynamically create, use, and delete a data source using the WebLogic management API.

See:
          Description

Class Summary
Client  
DynamicDataSourceHelper This class demonstrates dymamic creation, using and deletion of DataSource via Weblogic management API.
 

Package examples.jdbc.datasource.dynamic Description

This example shows how to dynamically create, use, and delete a data source using the WebLogic management API.

The example code in DynamicDataSourceHelper.java shows how to:

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

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

 

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

  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\datasource\dynamic directory.
  4. Execute the following command:
      ant
You should see the following results:
Buildfile: build.xml

compile:

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

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

all:

BUILD SUCCESSFUL

 

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 the following output in the command shell:

Buildfile: build.xml

run:
     [java] Creating Connection Pool...
     [java] Looping through all connection pools...
     [java] oraclePool
     [java] demoXAPool
     [java] OracleXAPool1
     [java] mssqlserverPool
     [java] OracleXAPool2
     [java] demoPool
     [java] Creating Connection Pool: dynamicDemoPool2
     [java] Starting up connection pool.
     [java]
     [java]
     [java] Creating Data Source...
     [java] Starting up DataSource
     [java] Getting Connection...
     [java] Deleting Data Source...

BUILD SUCCESSFUL

Total time: 7 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.