WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

examples.jdbc.mssqlserver4
Class ThreadsTests

java.lang.Object
  |
  +--examples.jdbc.mssqlserver4.ThreadsTests

public class ThreadsTests
extends java.lang.Object

This example creates n database connections and runs n threads on each. You need valid licenses for the number of connections you want to try. The trial version provides 2 connections only. Contact support@weblogic.com for more connection licenses. Your SQL Server must also be configured to accept the number of connections you want to create.

The threads run for a designated number of seconds, executing a SQL SELECT statement. You can modify the number of seconds and the SQL command in the code.

Build the Example

  1. Change the database user, password, server, and URL in the build.xml file in %SAMPLES_HOME%\server\src\examples\jdbc\mssqlserver4 to correspond to your Microsoft SQL Server configuration.

    Note: You may need sa privileges in SQL Server to run this example. When you specify a user and password, make sure the user has sa privileges in the database.

    If you need more help, check the section on connecting to a database in the programming guide, Using WebLogic jDriver for Microsoft SQL Server.

  2. Open a new command shell.

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

  4. Change your CLASSPATH if neccessary, depending on which version of WebLogic jDriver for Microsoft SQL Server you are using. If you are using Version 7.0 you do not need to make changes. If you are using Version 6.5, pre-pend your classpath as follows by adding the jar file:
      prompt> set CLASSPATH=%WL_HOME%/server/lib/mssqlserver4v65.jar;%CLASSPATH%

  5. Change the SQL Select statement in ThreadsTests.java to use an existing table on your SQL Server.

  6. Compile this example using the following command line:
      prompt> ant

    Note: This script builds all of the examples in the mssqlserver4 directory.

Run the Example

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

    Note: This script runs all of the examples in the mssqlserver4 directory.

There's More

For more information about the WebLogic jDriver for Microsoft SQL Server, see Using WebLogic jDriver for Microsoft SQL Server.

*

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

Field Summary
(package private) static java.lang.String driverName
           
(package private) static int kNumberOfConnections
           
(package private) static int kTestSeconds
           
(package private) static int kThreadsPerConnection
           
(package private) static int totalRows
           
(package private) static int totalRuns
           
 
Constructor Summary
ThreadsTests()
           
 
Method Summary
static void main(java.lang.String[] argv)
           
(package private) static void updateStatistics(int runs, int rows)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driverName

static java.lang.String driverName

kNumberOfConnections

static int kNumberOfConnections

kTestSeconds

static int kTestSeconds

kThreadsPerConnection

static int kThreadsPerConnection

totalRows

static int totalRows

totalRuns

static int totalRuns
Constructor Detail

ThreadsTests

public ThreadsTests()
Method Detail

main

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

updateStatistics

static void updateStatistics(int runs,
                             int rows)

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

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