|
|
| WebLogic Server 7.0 Code Examples, BEA Systems, Inc. |
|
SUMMARY: INNER | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD |
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
- Open a new command shell.
- Set up this development shell as described in
Setting up Your Environment for
Building and Running the Examples.
- Compile the example by executing an ant
build script or a command.
- An ant build script is available in the
samples\examples\jdbc\datasource directory. Enter the following command
to execute the build script:
ant
- Start WebLogic Server with the examples configuration.
Configure the Example
- Open the Administration Console.
- Verify that the Examples Web Application has been deployed on your server.
- Verify that examples-dataSource-demoPool (a txdatasource) points to the demoPool connection pool
and that the demoPool is enabled, as follows:
- Click to expand the JDBC node in the left-hand pane.
- Click to expand the Connection Pool node, then verify that demoPool appears under Connection Pool.
- Click the demoPool connection pool, then click the Targets and Servers tabs in the right pane. Make sure that examplesServer
is listed as a Chosen target server.
- Click to expand the Tx Data Sources node, then verify that examples-dataSource-demoPool appears under Tx Data Sources.
- Click the examples-dataSource-demoPool tx data source, then click the Configuration tab in the right pane. Make sure that
the Pool Name attribute is set to demoPool.
- Click the Targets and Servers tabs in the right pane. Make sure that examplesServer is listed as a Chosen target server.
Run the Example
- 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
- For more information on managing datasources and connection pools, see Managing WebLogic JDBC in the Administration Guide.
- For more information on datasources and connection pools, begin with Overview of Connection Pools and Overview of DataSources in Programming WebLogic JDBC.
- Author:
- Copyright (c) 2000-2002 by BEA Systems, Inc. All Rights Reserved.
|
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 |
simplesql
public simplesql()
main
public static void main(java.lang.String[] argv)
throws java.lang.Exception
Copyright © 2002 BEA Systems, Inc. All Rights Reserved.