WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

examples.jdbc.datasource
Class simplesql

java.lang.Object
  |
  +--examples.jdbc.datasource.simplesql

public class simplesql
extends java.lang.Object

This example demonstrates obtaining a database connection using a DataSource object. See the simplesql.java file for code details.

You use the Administration Console as well as the command line to build, compile, and run this example.

Build the Example

  1. Open a new command shell.

  2. Set up this development shell as described in Setting up Your Environment for Building and Running the Examples.

  3. Compile the example by executing an ant build script or a command.

  4. Start WebLogic Server with the examples configuration.

Configure the Example

  1. Open the Administration Console.

  2. Verify that the Examples Web Application has been deployed on your server.

  3. Verify that examples-dataSource-demoPool (a txdatasource) points to the demoPool connection pool and that the demoPool is enabled, as follows:

Run the Example

  1. Execute the following command in your development shell:
    prompt> ant run

Check the Output

When you run this example, the example makes a database connection using a tx data source and then performs some simple database opertaions. See the simplesql.java file for code details.

You should see the following results in the command window:

prompt>ant run
 Buildfile: build.xml
 
 run:
     [java] Making connection...
     [java]
     [java] Table empdemo doesn't need to be dropped.
     [java] Table empdemo created.
     [java] Number of rows inserted = 1
     [java] Number of rows deleted = 1
 
 BUILD SUCCESSFUL

There's more

Author:
Copyright (c) 2000-2002 by BEA Systems, Inc. All Rights Reserved.

Constructor Summary
simplesql()
           
 
Method Summary
static void main(java.lang.String[] argv)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

simplesql

public simplesql()
Method Detail

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception

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

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