WebLogic Application Server "How-To" Guide





WebLogic Application Server "How-To" Guide Expand / Collapse
How to use the Teradata JDBC Driver with WebLogic Server

Date: January 7, 2009




Abstract: The Teradata JDBC Driver Connection Pooling facility can greatly improve application performance. The steps used to enable it for the Teradata JDBC Driver will vary with the application server being used. This paper outlines the steps and parameters required to use the Teradata JDBC Driver with WebLogic application server.




TERADATA CONFIDENTIAL

Copyright © 2005-2009 by Teradata Corporation.

All Rights Reserved.

This document, which includes the information contained herein,: (i) is the exclusive property of Teradata Corporation; (ii) constitutes Teradata confidential information; (iii) may not be disclosed by you to third parties; (iv) may only be used by you for the exclusive purpose of facilitating your internal Teradata-authorized use of the Teradata product(s) described in this document to the extent that you have separately acquired a written license from Teradata for such product(s); and (v) is provided to you solely on an "as-is" basis. In no case will you cause this document or its contents to be disseminated to any third party, reproduced or copied by any means (in whole or in part) without Teradata's prior written consent. Any copy of this document, or portion thereof, must include this notice, and all other restrictive legends appearing in this document. Note that any product, process or technology described in this document may be the subject of other intellectual property rights reserved by Teradata and are not licensed hereunder. No license rights will be implied. Use, duplication or disclosure by the United States government is subject to the restrictions set forth in DFARS 252.227-7013 (c) (1) (ii) and FAR 52.227-19. Other brand and product names used herein are for identification purposes only and may be trademarks of their respective companies.






Table of Contents

1. Introduction


     1.1. Assumptions
     1.2. Purpose and Organization
     1.3. Version Information
     1.4. Supported Platform Matrix
     1.5. C/C++ and Java Application Sharing of TeraGSS Security Configuration
     1.6. Overview - Data Source in WebLogic Server

2. WebLogic 8.1


     2.1. Connection Pool via Administrative Console
        2.1.1. Prerequisites
        2.1.2. Start the Administrative Console
        2.1.3. Open JDBC Connection Pools
        2.1.4. Set Connection Pool Parameters
        2.1.5. Create the Pool
        2.1.6. Assign the Pool
     2.2. Create JDBC Data Source
        2.2.1. Start the Administrative Console
        2.2.2. Open JDBC Data Sources
        2.2.3. Set Data Source Parameters
        2.2.4. Assign the Data Source
     2.3. Accessing the DataSource from a Java Application
        2.3.1. DataSource.getConnection() vs. DataSource.getConnection(username,password)
        2.3.2. Using the DataSource
     2.4. Performance Parameters
        2.4.1. Advanced Options

3. WebLogic 9.x and WebLogic 10.x


     3.1. Create JDBC Data Source
        3.1.1. Prerequisites
        3.1.2. Start the Administrative Console
        3.1.3. Open JDBC Data Sources
        3.1.4. Set Data Source Parameters
        3.1.5. Set the Transaction Options
        3.1.6. Set the Connection Properties
        3.1.7. Test the Database Connection and Connection Properties
        3.1.8. Assign the Data Source
     3.2. Accessing the Data Source from a Java Application
        3.2.1. DataSource.getConnection() vs. DataSource.getConnection(username,password)
        3.2.2. Using the Data Source
     3.3. Performance Parameters
        3.3.1. Advanced Options

4. WebLogic 10.3


     4.1. Create JDBC Data Source
        4.1.1. Prerequisites
        4.1.2. Start the Administrative Console
        4.1.3. Open JDBC Data Sources
        4.1.4. Set Data Source Parameters
        4.1.5. Set the Transaction Options
        4.1.6. Set the Connection Properties
        4.1.7. Test the Database Connection and Connection Properties
        4.1.8. Assign the Data Source
     4.2. Accessing the Data Source from a Java Application
        4.2.1. DataSource.getConnection() vs. DataSource.getConnection(username,password)
        4.2.2. Using the Data Source
     4.3. Performance Parameters
        4.3.1. Advanced Options

5. Troubleshooting


     5.1. Session Defaults Warning
     5.2. Preparation of CMP Entity Beans for Deployment

Appendix A: WebLogic Code Samples








1. Introduction

The Teradata JDBC Driver provides an open interface to the Teradata Database. When the Teradata JDBC Driver is used in an application server, significant performance gains can be realized by using connection pools instead of non-pooled connections. This paper outlines the specific steps and settings required to enable connection pooling for the Teradata JDBC Driver with a supported application server.



1.1. Assumptions

This paper assumes that the reader is already familiar with the application server being used and has copied the Teradata JDBC Driver product to a system containing this application server. You should also know how to start the appropriate administrative console and have the required permissions that allow you to change operating parameters.

Though an understanding of the Java programming language shouldn't be necessary for learning how to set up Connection Pools, it is necessary to understand how to use them after they have been set up.

Please note that the screen shots used in the examples were taken on a Microsoft Windows system. The actual interface that you see on different platforms supported by the application servers may vary.



1.2. Purpose and Organization

The purpose of this paper is to provide all of the details necessary to set up and use Connection Pools for the Teradata JDBC Driver with a supported application server.



1.3. Version Information

The application server versions used are:

  • WebLogic Server 8.1
  • WebLogic Server 9.0
  • WebLogic Server 9.1
  • WebLogic Server 9.2
  • WebLogic Server 10.0
  • WebLogic Server 10.3


1.4. Supported Platform Matrix

Java Virtual Machine (JVM) and Application Server support by TTU/JDBC Driver release

u=unsupported / s=supported

TTU 7.1
JDBC 3.1
TTU 8.0
JDBC 3.2
TTU 8.1
JDBC 3.3
TTU 8.2
JDBC 3.4
TTU 12.0
JDBC 12.0
TTU 13.0
JDBC 13.0
JVM 1.3.x s u u u u u
JVM 1.4.x s s s s s s
JVM 5.0 u s s s s s
JVM 6.0 u u u s s s
WebSphere 5.0 with IBM JVM 1.3.1 s u u u u u
WebSphere 5.1 with IBM JVM 1.4.1 u s s s s s
WebSphere 6.0 with IBM JVM 1.4.2 u s s s s s
WebSphere 6.1 with IBM JVM 5.0 u s s s s s
WebSphere 7.0 with IBM JVM 6.0 u u u s s s
WebLogic 7.0 with Sun JVM 1.3.1 s u u u u u
WebLogic 7.0 with JRockit JVM 1.3.1 u u u u u u
WebLogic 8.1 with Sun JVM 1.4.1 or 1.4.2 s s s s s s
WebLogic 8.1 with JRockit JVM 1.4.1 or 1.4.2 u u s s s s
WebLogic 9.0 with Sun JVM 5.0 u u s s s s
WebLogic 9.0 with JRockit JVM 5.0 u u s s s s
WebLogic 9.1 with Sun JVM 5.0 u u s s s s
WebLogic 9.1 with JRockit JVM 5.0 u u s s s s
WebLogic 9.2 with Sun JVM 5.0 u u s s s s
WebLogic 9.2 with JRockit JVM 5.0 u u s s s s
WebLogic 10.0 with Sun JVM 5.0 u u u s s s
WebLogic 10.0 with JRockit JVM 5.0 u u u s s s
WebLogic 10.3 with Sun JVM 6.0 u u u s s s
WebLogic 10.3 with JRockit JVM 6.0 u u u s s s
ColdFusion MX 6.1 Server Configuration with Sun JVM 1.4.2 s s s s s s
ColdFusion MX 6.1 JRun 4 Configuration with Sun JVM 1.4.2 s s s s s s
ColdFusion MX 6.1 J2EE Configuration in third-party application server u u u u u u
ColdFusion MX 7 Server Configuration with Sun JVM 1.4.2 s s s s s s
ColdFusion MX 7 JRun 4 Configuration with Sun JVM 1.4.2 s s s s s s
ColdFusion MX 7 J2EE Configuration in third-party application server u u u u u u
ColdFusion 8 Server Configuration with Sun JVM 1.4.2 u u u s s s
ColdFusion 8 Server Configuration with Sun JVM 5.0 u u u s s s
ColdFusion 8 Server Configuration with Sun JVM 6.0 u u u s s s
ColdFusion 8 Multiserver (JRun 4) Configuration with Sun JVM 1.4.2 u u u s s s
ColdFusion 8 Multiserver (JRun 4) Configuration with Sun JVM 5.0 u u u s s s
ColdFusion 8 Multiserver (JRun 4) Configuration with Sun JVM 6.0 u u u s s s
ColdFusion 8 J2EE Configuration in third-party application server u u u u u u
JBoss 3.2.3 with Sun JVM 1.4.2 u s s s s s
JBoss 4.0 with Sun JVM 1.4.2 u u s s s s
JBoss 4.0 with Sun JVM 5.0 u u s s s s
SAP Web AS 6.40 with Sun JVM 1.4.2 u s s s s s
Tomcat 5.5 with Sun JVM 5.0 u u u s s s
Tomcat 6.0 with Sun JVM 5.0 u u u s s s

Please refer to the Teradata JDBC Driver User Guide for each Teradata JDBC Driver release, to obtain the list of supported combinations of operating systems, CPUs, and 32/64 bit modes for that Teradata JDBC Driver release.

Please refer to the application server vendor's documentation to obtain the list of supported combinations of operating systems, CPUs, and 32/64 bit modes for each application server version.

The Teradata JDBC Driver is supported for use with all combinations of operating systems, CPUs, and 32/64 bit modes that are supported by both the application server version and the Teradata JDBC Driver release.

For Java software, an operating environment consists of the complete combination of the following items:

  • the specific version of the underlying operating system
  • the specific JVM version
  • the 32-bit or 64-bit mode of the JVM
  • the specific version of the application server, if an application server is used.

Generally, the Teradata JDBC Driver is tested in a particular operating environment before that operating environment is supported for use with the Teradata JDBC Driver. Such testing is needed for the following reasons:

  • to verify the correct operation of the Teradata JDBC Driver
  • to identify the minimum patch level needed for the underlying operating system version
  • to identify the minimum patch level needed for the JVM version
  • to ensure documentation, such as workarounds or Tech alerts, is available for the Global Support Center (GSC), so that it can support customers.

If a problem is encountered while using the Teradata JDBC Driver in an unsupported environment, then the GSC will attempt to reproduce the problem in the closest supported environment. If the problem can be reproduced in a supported environment, and the problem is determined to be due to the Teradata JDBC Driver, then the problem will be corrected and retested using the supported platform.



1.5. C/C++ and Java Application Sharing of TeraGSS Security Configuration

C/C++ applications that communicate with the Teradata Database use the TeraGSS security library. If C/C++ and Java applications are deployed to the same physical machine, then Java applications can be configured to use the TeraGSS security library's User Configuration File.

In this deployment scenario, Java applications do not use the tdgssconfig.jar file that is included in the Teradata JDBC Driver download package. Instead, the classpath for Java applications must include the TeraGSS directory that contains the TeraGSS User Configuration File, TdgssUserConfigFile.xml, as follows:

For shared TeraGSS configuration using the

The classpath must include

TTU 12.0 Teradata JDBC Driver and later terajdbc4.jar
The directory containing TdgssUserConfigFile.xml
TTU 8.2 Teradata JDBC Driver 3.4 and earlier terajdbc4.jar
tdgssjava.jar
The directory containing TdgssUserConfigFile.xml

For standalone Java applications, this is done via the applications' classpath. For J2EE applications deployed to an application server environment, the Data Source classpath is modified.

Not all classloaders support the specification of a directory on the classpath. This deployment technique can only be used with classloaders that support the specification of a directory on the classpath.

Some application servers, such as SAP Web Application Server, only support the use of jar files when defining the classpath for a JDBC Data Source. If the application server or environment does not support the specification of a directory on the classpath, then C/C++ and Java applications cannot directly share the same TeraGSS User Configuration File.

For application servers or environments that do not support the specification of a directory on the classpath, the TeraGSS User Configuration File can only be shared indirectly, and an extra step must be performed to enable this indirect sharing.

A jar "update" command must be executed to take the TeraGSS User Configuration File from the TeraGSS directory and to put the TeraGSS User Configuration File into the tdgssconfig.jar file from the Teradata JDBC Driver download package via:

jar uvf tdgssconfig.jar TdgssUserConfigFile.xml

Each time the TeraGSS User Configuration File is modified, the jar "update" command must be executed again. The application server or environment must be restarted so that the modified tdgssconfig.jar will be used.



1.6. Overview - Data Source in WebLogic Server

This section provides a quick overview of Data Source configuration in WebLogic. More detail is provided in subsequent sections.

The Teradata JDBC Driver can be used as a WebLogic Server data source. Within WebLogic Server, the use of a DataSource object, instead of DriverManager, is the preferred means of connecting to a data source.

To use the DataSource interface within WebLogic Server, the JDBC Connection Pool and JDBC Data Source will need to be configured for the Teradata JDBC Driver.

When configuring the JDBC Connection Pool through WebLogic server Admin Console, the following Teradata-specific configuration parameters are needed.

For the "Choose database" pane:

  • Database Type: Other
  • Database Driver: Other

For the "JDBC Data Source Properties" pane for WebLogic 9.x and WebLogic 10.x:

  • Database Type: Other
  • Database Driver: Other

NOTE: In WebLogic 9.1, "Other" is not available as a Database Type. Instead, an arbitrary value for the database type can be chosen. The database type of PointBase has been tested to work successfully with the Teradata JDBC Driver.

For the "Define and test connection" pane:

Driver Classname

Use com.teradata.jdbc.TeraDriver with the TTU 12.0 Teradata JDBC Driver and later.
Use com.ncr.teradata.TeraDriver with the TTU 8.2 Teradata JDBC Driver 3.4 and earlier.
com.teradata.jdbc.TeraDriver
URLjdbc:teradata://DataSourceName

NOTE: In WebLogic 9.x and WebLogic 10.x, the Driver Classname and the URL is defined in the "Test Database Connection" pane.

When configuring the JDBC Data Source through WebLogic server Admin Console, the following parameter settings are required for setting up a plain data source and TXDataSource.

For a "Plain Data Source":

    [WebLogic 8.1]

  • Checkbox "Honor Global Transactions" should be unchecked.
  • Checkbox "Emulate Two-Phase Commit for non-XA Driver" should be checked.

    [WebLogic 9.x and WebLogic 10.x]

  • Checkbox "Supports Global Transactions" should be unchecked.
  • Checkbox "Emulate Two-Phase Commit" should be unchecked.

For a "TXDataSource":

    [WebLogic 8.1]

  • Checkbox "Honor Global Transactions" should be checked.
  • Checkbox "Emulate Two-Phase Commit for non-XA Driver" should be checked.

    [WebLogic 9.x and WebLogic 10.x]

  • Checkbox "Supports Global Transactions" should be checked.
  • Checkbox "Emulate Two-Phase Commit" should be checked.



2. WebLogic 8.1

The recommended way to create a Connection Pool within WebLogic is to use the graphical interface of the administrative server.



2.1. Connection Pool via Administrative Console



2.1.1. Prerequisites

Prior to starting WebLogic, you must ensure that the CLASSPATH of the server refers to the jar files that make up the Teradata JDBC Driver.

For example, if you copied all of these to C:\TeraJDBC, then your CLASSPATH would need to include:

  • C:\TeraJDBC\terajdbc4.jar
  • C:\TeraJDBC\tdgssconfig.jar

Note: When using the TTU 8.2 Teradata JDBC Driver 3.4 and earlier, tdgssjava.jar must also be included. This file is not used by the TTU 12.0 Teradata JDBC Driver and later.

Note: If you are sharing the TeraGSS Security Configuration (see section 1.5), replace tdgssconfig.jar with the directory containing TdgssUserConfigFile.xml



2.1.2. Start the Administrative Console

Use the Desktop "Start" button as follows:

Start → Programs → BEA WebLogic Platform 8.1 → Examples → WebLogic Server Examples → Server Admin Console



2.1.3. Open JDBC Connection Pools

In the left pane, click to expand the "examples" node

Click to expand the "Services" node

Click to expand the "JDBC" node in Services

Click on "Connection Pools" in JDBC

The right pane will show all of the Connection Pools currently defined.

Click "Configure a new JDBC Connection Pool..."



2.1.4. Set Connection Pool Parameters

Select "Other" for the Database Type

"Other" is automatically selected for the Database Driver

Press "Continue"

Next, the details of the Teradata Connection Pool must be filled in.



2.1.5. Create the Pool

The values required to create the connection pool are listed in the following table. Please note that the username of "guest" and password of "please" are examples and should be replaced by the actual username/password combination for your Teradata Database system.

Field

Value

Example

Name

The name of the connection pool. This value is user-defined. tera4

Driver Classname

The name of the class that implements the java.sql.Driver interface.

Use com.teradata.jdbc.TeraDriver with the TTU 12.0 Teradata JDBC Driver and later.
Use com.ncr.teradata.TeraDriver with the TTU 8.2 Teradata JDBC Driver 3.4 and earlier.
com.teradata.jdbc.TeraDriver

URL

Defines the URL that will be passed to the driver. The example Teradata Database name is "whomooz". You should use the actual Teradata Database hostname for your site.

Please note that any connection URL parameter such as "CHARSET" or "TMODE" must be set within this URL parameter. These CANNOT be set within the properties panel.
jdbc:teradata://whomooz

Database User Name

The Teradata Database username. guest

Password

The password of the Teradata Database user.

This can be used to override the password value in Properties. It allows you to avoid storing cleartext passwords.

After this value is applied it will not be visible as cleartext in the panel.
please

Fill in the connection properties as shown in the figure below.

Click "Test Driver Configuration" to check for errors. If there are no errors, click "Continue".



2.1.6. Assign the Pool

To create and deploy the pool click "Create and deploy" as shown in the figure below.



2.2. Create JDBC Data Source

The JDBC Data Source allows you to access a connection pool. Using a Data Source enables an application to be independent of both the actual database being accessed and the type of JDBC driver being used.



2.2.1. Start the Administrative Console

Use the Desktop "Start" button as follows:

Start → Programs → BEA WebLogic Platform 8.1 → Examples → WebLogic Platform → Server Admin Console



2.2.2. Open JDBC Data Sources

In the left pane, click to expand the "examples" node

Click to expand the "Services" node

Click to expand the "JDBC" node in Services

Click the "Data Sources" node in JDBC

The right pane will show all of the Data Sources currently defined.

Select "Configure a new JDBC Data Source"



2.2.3. Set Data Source Parameters

The following table lists the parameters that must be set for a Data Source.

Field

Value

Example

Name

The user-defined display name for this DataSource. tera4DataSource

JNDI Name

User-defined JNDI name of the DataSource. tera4DS

Honor Global Transactions

Specifies whether the Data Source can be treated as a javax.sql.XADataSource that supports distributed transactions. This box should be checked if you are using Container Managed Persistence (CMP) Entity Beans. Otherwise, it should remain unchecked. (unchecked)

Emulate Two-Phase Commit for non-XA Driver

Specifies that the JDBC driver is not a javax.sql.XADataSource, and that the JDBC driver does not support distributed transactions. The Teradata JDBC Driver does not currently support XA or distributed transactions. (checked)

Enter the appropriate Teradata Database parameters, as shown in the figure below. Be sure that "Emulate Two-Phase Commit for non-XA Driver" is checked. Press "Continue" when you are finished.

Next, associate the JDBC data source with a connection pool, as shown in the figure below.

Select the connection pool name you defined in the last step from the Pool Name combo box.

Press "Continue".



2.2.4. Assign the Data Source

Select the target server. In this example, select "examplesServer" as shown in the figure below.

Press "Create" to create the data source.



2.3. Accessing the DataSource from a Java Application



2.3.1. DataSource.getConnection() vs. DataSource.getConnection(username,password)

WebLogic requires a valid Teradata Database username and password to be specified in the connection pool definition. The Teradata Database username and password specified in the connection pool definition are the ones that are always used to connect to the Teradata Database.

When the application calls DataSource.getConnection(), then the username and password specified in the connection pool definition are used to connect to the Teradata Database.

When the application calls DataSource.getConnection(username,password), then the username and password arguments to getConnection are validated against the WebLogic server realm.

If there is no WebLogic user defined in the WebLogic server realm that corresponds to the username argument to getConnection, then WebLogic will throw the following SQLException:

    Message: "User: YourUserId, failed to be authenticated."
    SQLState: null
    Error code: 0

If the username and password arguments to getConnection are successfully validated against the WebLogic server realm, then the username and password specified in the connection pool definition are used to connect to the Teradata Database.

Note: The username and password arguments to getConnection are totally separate from the username and password specified in the connection pool definition. The username and password arguments to getConnection are used by WebLogic only, and are validated against the WebLogic server realm. The username and password arguments to getConnection are NOT used for the Teradata Database.

Note: This behavior of WebLogic differs from the JDBC API standard, and it differs from the behavior of other application servers.



2.3.2. Using the DataSource

The following code creates the initial context:

Context ctx = new InitialContext();

To perform a JNDI lookup to obtain the DataSource, the following code can be used:

DataSource ds = (DataSource) ctx.lookup(jndiName);

To obtain a connection from the DataSource, the following code can be used:

Connection con = ds.getConnection();

At this point, the connection obtained behaves the same way as one that was obtained from the Driver Manager.

See Appendix A for a complete application.



2.4. Performance Parameters

The following performance parameters are visible after selecting a specific Connection Pool and then selecting the "Connections" tab within the WebLogic Administrator Console. Their setting can impact the performance of your application.

Maximum Capacity - too small of a value here can cause users of the pool to waste time waiting for someone to release a connection.



2.4.1 Advanced Options

Login Delay - this defaults to zero and should remain at that value. Inserting a value here could cause unnecessary delays.

Test Created Connections - selecting this option will hurt your performance with no apparent benefit to your application.

Test Reserved Connections - this determines whether connections are tested before being given to a client. Turning on this option will cause your application to run slightly slower, but it will take advantage of WebLogic's automatic testing of connections, so that your application won't need to handle the situation where the connection it gets is not working. Turning off this option will cause your application to run slightly faster, but it will not use WebLogic's automatic testing of connections, so that your application will need to handle the situation where the connection it gets is not working.

Test Table Name - a table the DataSource user has access to which contains a small number of rows. The SQL executed will be: select count(*) from TestTableName

Also note that there is a Monitoring Tab available that can help you track the performance of a Connection Pool.




3. WebLogic 9.x and WebLogic 10.x

The recommended way to create a Data Source and Connection Pool within WebLogic is to use the graphical interface of the administrative server.



3.1. Create JDBC Data Source

The creation of a Data Source and Connection Pool differs between WebLogic 9.x,WebLogic 10.x and previous versions of WebLogic that are supported by the Teradata JDBC Driver. In WebLogic 9.x and WebLogic 10.x, the Data Source and Connection Pool are not defined separately, instead the Connection Pool is created within the Data Source creation when defining the connection properties and parameters to test the data source configuration.



3.1.1. Prerequisites

Prior to starting WebLogic, you must ensure that the CLASSPATH of the server refers to the jar files that make up the Teradata JDBC Driver.

For example, if you copied all of these to C:\TeraJDBC, then your CLASSPATH would need to include:

  • C:\TeraJDBC\terajdbc4.jar
  • C:\TeraJDBC\tdgssconfig.jar

Note: When using the TTU 8.2 Teradata JDBC Driver 3.4 and earlier, tdgssjava.jar must also be included. This file is not used by the TTU 12.0 Teradata JDBC Driver and later.

Note: If you are sharing the TeraGSS Security Configuration (see section 1.5), replace tdgssconfig.jar with the directory containing TdgssUserConfigFile.xml



3.1.2. Start the Administrative Console

Use the Desktop "Start" button as follows:

Start → Programs → BEA Products → Examples → WebLogic Server → Start Examples Server

When the browser window is displayed for WEBLOGIC SERVER 9.x or WEBLOGIC SERVER 10.x Getting Started, Click "Start the Administration Console" at the top right.

Enter your username and password (default is weblogic)



3.1.3. Open JDBC Data Sources

In the left pane for Domain Structure, click to expand the "Services" node.

Click to expand the "JDBC" node in Services.

Click on "Data Sources" in JDBC.

The right pane will show all of the Data Sources currently defined.

Click "Lock & Edit" in the left pane for the Change Center.

Click "New" in the Data Sources pane.



3.1.4. Set Data Source Parameters

The following table lists the parameters that must be set for a Data Source.

Field

Value

Example

Name

The user-defined display name for this Data Source. tera4DataSource

JNDI Name

User-defined JNDI name of the Data Source. tera4DS

Database Type

The database type to be used.
NOTE: In WebLogic 9.1, "Other" is not available as a database type. Since neither Teradata nor Other is available in this list, an arbitrary value for the database type can be chosen. The database type of PointBase has been tested to work successfully with the Teradata JDBC Driver.
Other

Database Driver

The database driver to use to create database connections. Other


Enter the appropriate parameters, as shown in the figure below. Click "Next" when you are finished.




3.1.5. Set the Transaction Options

For the Transaction Options shown below, uncheck "Supports Global Transactions". Click "Next" when you are finished.

NOTE: In WebLogic 9.x and Weblogic 10.x, an option for transaction processing, e.g. Emulate Two-Phase Commit, can be set only if you selected Supports Global Transactions. For TXDataSource, both of the check boxes for "Supports Global Transactions" and "Emulate Two-Phase Commit" should be checked.



3.1.6. Set the Connection Properties

The following table lists the parameters to be set for Connection Properties which will be used to create the connection pool for this data source.

Please note that the username of "guest" and password of "please" are examples and should be replaced by the actual username/password combination for your Teradata Database system.

Field

Value

Example

Database Name

The example Teradata Database name is "whomooz". You should use the actual Teradata Database hostname for your site. whomooz

Host Name

The name or IP address of the database server. whomooz

Port

The port on the database server used to connect to the Teradata Database.

NOTE: This port number setting is not currently used by the Teradata JDBC Driver to connect to the Teradata Database. However, this port number setting may be supported by the Teradata JDBC Driver in the future, so it should be set correctly for your Teradata Database system. The Teradata Database normally uses port 1025.

If your Teradata Database system uses a port other than 1025, then the port number can be specified with the DBS_PORT connection URL parameter. Setting the connection URL is shown in the next section.
1025

Database User Name

The Teradata Database username. guest

Password

The password of the Teradata Database user.

This can be used to override the password value in Properties. It allows you to avoid storing cleartext passwords.

After this value is applied it will not be visible as cleartext in the panel.
please


Enter the appropriate parameters, as shown in the figure below. Click "Next" to continue.




3.1.7. Test the Database Connection and Connection Properties

The following table lists the parameters that must be set for the Test Database Connection.

The values required to create the connection pool are listed in the following table. Please note that the username of "guest" and password of "please" are examples and should be replaced by the actual username/password combination for your Teradata Database system.

Field

Value

Example

Driver Class Name

The name of the class that implements the java.sql.Driver interface.

This value will be used to define the driver class name for the connection pool for this data source.

Use com.teradata.jdbc.TeraDriver with the TTU 12.0 Teradata JDBC Driver and later.
Use com.ncr.teradata.TeraDriver with the TTU 8.2 Teradata JDBC Driver 3.4 and earlier.
com.teradata.jdbc.TeraDriver

URL

Defines the URL that will be passed to the driver. The example Teradata Databasename is "whomooz". You should use the actual Teradata Database hostname for your site.

This value will be used to define the URL for the connection pool for this data source.

Please note that any connection URL parameter such as "CHARSET" or "TMODE" must be set within this URL parameter. These CANNOT be set within the properties panel.
jdbc:teradata://whomooz

Database User name

The Teradata Database username. guest

Password

The password of the Teradata Database user.

This can be used to override the password value in Properties. It allows you to avoid storing cleartext passwords.

After this value is applied it will not be visible as cleartext in the panel.
please

Confirm Password

Re-enter the password of the Teradata Database user. please

Properties

The properties to pass to the JDBC driver when creating the database connection. user=guest

Test Table Name

The table name or SQL statement to use to test the database connection.

NOTE: This property is optional.
SQL select count(*) from TestTableName


Enter the appropriate parameters, as shown in the figure below. Click "Test Configuration" when you are finished. In the Messages window, you should receive "Connection test succeeded." if your connection was successful. Click "Next" to continue.




3.1.8. Assign the Data Source

Select the target to deploy the JDBC Data Source. examplesServer is used for this Data Source.



Click "Finish" to complete the Data Source creation.

Click the "Activate Change" button in the Change Center to activate the changes.

The Data Source that you just created should now appear in the table for the Data Sources for this domain.



3.2. Accessing the Data Source from a Java Application


3.2.1. DataSource.getConnection() vs. DataSource.getConnection(username,password)

WebLogic requires a valid Teradata Database username and password to be specified in the connection pool definition. The Teradata Database username and password specified in the connection pool definition are the ones that are always used to connect to the Teradata Database.

When the application calls DataSource.getConnection(), then the username and password specified in the connection pool definition are used to connect to the Teradata Database.

When the application calls DataSource.getConnection(username,password), then the username and password arguments to getConnection are validated against the WebLogic server realm.

If there is no WebLogic user defined in the WebLogic server realm that corresponds to the username argument to getConnection, then WebLogic will throw the following SQLException:

    Message: "User: YourUserId, failed to be authenticated."
    SQLState: null
    Error code: 0

If the username and password arguments to getConnection are successfully validated against the WebLogic server realm, then the username and password specified in the connection pool definition are used to connect to the Teradata Database.

Note: The username and password arguments to getConnection are totally separate from the username and password specified in the connection pool definition. The username and password arguments to getConnection are used by WebLogic only, and are validated against the WebLogic server realm. The username and password arguments to getConnection are NOT used for the Teradata Database.

Note: This behavior of WebLogic differs from the JDBC API standard, and it differs from the behavior of other application servers.



3.2.2. Using the Data Source

The following code creates the initial context:

Context ctx = new InitialContext();

To perform a JNDI lookup to obtain the Data Source, the following code can be used:

DataSource ds = (DataSource) ctx.lookup(jndiName);

To obtain a connection from the Data Source, the following code can be used:

Connection con = ds.getConnection();

At this point, the connection obtained behaves the same way as one that was obtained from the Driver Manager.

See Appendix A for a complete application.



3.3. Performance Parameters

The following performance parameters are visible after selecting Connection Pool under the "Configuration" tab for a Data Source within the WebLogic Administrator Console. Their setting can impact the performance of your application.

Maximum Capacity - This value specifies the maximum number of connections that the pool can contain. If this value is set smaller than the number of connections normally in use, then application response time may be negatively impacted as the application must wait for connections to be returned to the pool before proceeding.



3.3.1 Advanced Options

Login Delay - this defaults to zero and should remain at that value. Inserting a value here could cause unnecessary delays.

Test Connections on Reserve - this determines whether connections are tested before being given to a client. Turning on this option will cause your application to run slightly slower, but it will take advantage of WebLogic's automatic testing of connections, so that your application won't need to handle the situation where the connection it gets is not working. Turning off this option will cause your application to run slightly faster, but it will not use WebLogic's automatic testing of connections, so that your application will need to handle the situation where the connection that is obtained from the pool may not work.

Test Table Name - a table the Data Source user has access to which contains a small number of rows. The SQL executed will be: select count(*) from TestTableName

Also note that there is a Monitoring Tab available that can help you track the performance of a data source.




4. WebLogic 10.3

The recommended way to create a Data Source and Connection Pool within WebLogic is to use the graphical interface of the administrative server.



4.1. Create JDBC Data Source

The creation of a Data Source and Connection Pool differs between WebLogic 10.x and pre 9.1 versions of WebLogic that are supported by the Teradata JDBC Driver. In WebLogic 10.x, the Data Source and Connection Pool are not defined separately, instead the Connection Pool is created within the Data Source creation when defining the connection properties and parameters to test the data source configuration.



4.1.1. Prerequisites

Prior to starting WebLogic, you must ensure that the CLASSPATH of the server refers to the jar files that make up the Teradata JDBC Driver.

For example, if you copied all of these to C:\TeraJDBC, then your CLASSPATH would need to include:

  • C:\TeraJDBC\terajdbc4.jar
  • C:\TeraJDBC\tdgssconfig.jar

Note: When using the TTU 8.2 Teradata JDBC Driver 3.4 and earlier, tdgssjava.jar must also be included. This file is not used by the TTU 12.0 Teradata JDBC Driver and later.

Note: If you are sharing the TeraGSS Security Configuration (see section 1.5), replace tdgssconfig.jar with the directory containing TdgssUserConfigFile.xml



4.1.2. Start the Administrative Console

Use the Desktop "Start" button as follows:

Start → Programs → Oracle WebLogic → WebLogic Server 10gR3 → Examples → Start Examples Server

When the browser window is displayed for WEBLOGIC SERVER Getting Started, Click "Start the Administration Console" at the top right.

Enter your username and password (default is weblogic)



4.1.3. Open JDBC Data Sources

In the left pane for Domain Structure, click to expand the "Services" node.

Click to expand the "JDBC" node in Services.

Click on "Data Sources" in JDBC.

The right pane will show all of the Data Sources currently defined.

Click "New" in the Data Sources pane.



4.1.4. Set Data Source Parameters

The following table lists the parameters that must be set for a Data Source.

Field

Value

Example

Name

The user-defined display name for this Data Source. tera4DataSource

JNDI Name

User-defined JNDI name of the Data Source. tera4DS

Database Type

The database type to be used.
Other

Database Driver

The database driver to use to create database connections. Other


Enter the appropriate parameters, as shown in the figure below. Click "Next" when you are finished.




4.1.5. Set the Transaction Options

For the Transaction Options shown below, uncheck "Supports Global Transactions". Click "Next" when you are finished.

NOTE: In WebLogic 9.x and Weblogic 10.x, an option for transaction processing, e.g. Emulate Two-Phase Commit, can be set only if you selected Supports Global Transactions. For TXDataSource, both of the check boxes for "Supports Global Transactions" and "Emulate Two-Phase Commit" should be checked.



4.1.6. Set the Connection Properties

The following table lists the parameters to be set for Connection Properties which will be used to create the connection pool for this data source.

Please note that the username of "guest" and password of "please" are examples and should be replaced by the actual username/password combination for your Teradata Database system.

Field

Value

Example

Database Name

The example Teradata Database name is "xpsys03". You should use the actual Teradata Database hostname for your site. xpsys03

Host Name

The name or IP address of the database server. xpsys03

Port

The port on the database server used to connect to the Teradata Database.

NOTE: This port number setting is not currently used by the Teradata JDBC Driver to connect to the Teradata Database. However, this port number setting may be supported by the Teradata JDBC Driver in the future, so it should be set correctly for your Teradata Database system. The Teradata Database normally uses port 1025.

If your Teradata Database system uses a port other than 1025, then the port number can be specified with the DBS_PORT connection URL parameter. Setting the connection URL is shown in the next section.
1025

Database User Name

The Teradata Database username. guest

Password

The password of the Teradata Database user.

This can be used to override the password value in Properties. It allows you to avoid storing cleartext passwords.

After this value is applied it will not be visible as cleartext in the panel.
please


Enter the appropriate parameters, as shown in the figure below. Click "Next" to continue.




4.1.7. Test the Database Connection and Connection Properties

The following table lists the parameters that must be set for the Test Database Connection.

The values required to create the connection pool are listed in the following table. Please note that the username of "guest" and password of "please" are examples and should be replaced by the actual username/password combination for your Teradata Database system.

Field

Value

Example

Driver Class Name

The name of the class that implements the java.sql.Driver interface.

This value will be used to define the driver class name for the connection pool for this data source.

Use com.teradata.jdbc.TeraDriver with the TTU 12.0 Teradata JDBC Driver and later.
Use com.ncr.teradata.TeraDriver with the TTU 8.2 Teradata JDBC Driver 3.4 and earlier.
com.teradata.jdbc.TeraDriver

URL

Defines the URL that will be passed to the driver. The example Teradata Databasename is "xpsys03". You should use the actual Teradata Database hostname for your site.

This value will be used to define the URL for the connection pool for this data source.

Please note that any connection URL parameter such as "CHARSET" or "TMODE" must be set within this URL parameter. These CANNOT be set within the properties panel.
jdbc:teradata://xpsys03

Database User name

The Teradata Database username. guest

Password

The password of the Teradata Database user.

This can be used to override the password value in Properties. It allows you to avoid storing cleartext passwords.

After this value is applied it will not be visible as cleartext in the panel.
please

Confirm Password

Re-enter the password of the Teradata Database user. please

Properties

The properties to pass to the JDBC driver when creating the database connection. user=guest

Test Table Name

The table name or SQL statement to use to test the database connection.

NOTE: This property is optional.
SQL select count(*) from TestTableName


Enter the appropriate parameters, as shown in the figure below. Click "Test Configuration" when you are finished. In the Messages window, you should receive "Connection test succeeded." if your connection was successful. Click "Next" to continue.




4.1.8. Assign the Data Source

Select the target to deploy the JDBC Data Source. examplesServer is used for this Data Source.



Click "Finish" to complete the Data Source creation.

The Data Source that you just created should now appear in the table for the Data Sources for this domain.



4.2. Accessing the Data Source from a Java Application


4.2.1. DataSource.getConnection() vs. DataSource.getConnection(username,password)

WebLogic requires a valid Teradata Database username and password to be specified in the connection pool definition. The Teradata Database username and password specified in the connection pool definition are the ones that are always used to connect to the Teradata Database.

When the application calls DataSource.getConnection(), then the username and password specified in the connection pool definition are used to connect to the Teradata Database.

When the application calls DataSource.getConnection(username,password), then the username and password arguments to getConnection are validated against the WebLogic server realm.

If there is no WebLogic user defined in the WebLogic server realm that corresponds to the username argument to getConnection, then WebLogic will throw the following SQLException:

    Message: "User: YourUserId, failed to be authenticated."
    SQLState: null
    Error code: 0

If the username and password arguments to getConnection are successfully validated against the WebLogic server realm, then the username and password specified in the connection pool definition are used to connect to the Teradata Database.

Note: The username and password arguments to getConnection are totally separate from the username and password specified in the connection pool definition. The username and password arguments to getConnection are used by WebLogic only, and are validated against the WebLogic server realm. The username and password arguments to getConnection are NOT used for the Teradata Database.

Note: This behavior of WebLogic differs from the JDBC API standard, and it differs from the behavior of other application servers.



4.2.2. Using the Data Source

The following code creates the initial context:

Context ctx = new InitialContext();

To perform a JNDI lookup to obtain the Data Source, the following code can be used:

DataSource ds = (DataSource) ctx.lookup(jndiName);

To obtain a connection from the Data Source, the following code can be used:

Connection con = ds.getConnection();

At this point, the connection obtained behaves the same way as one that was obtained from the Driver Manager.

See Appendix A for a complete application.



4.3. Performance Parameters

The following performance parameters are visible after selecting Connection Pool under the "Configuration" tab / "Connection Pool" subtab - for a Data Source within the WebLogic Administrator Console. Their setting can impact the performance of your application.

Maximum Capacity - This value specifies the maximum number of connections that the pool can contain. If this value is set smaller than the number of connections normally in use, then application response time may be negatively impacted as the application must wait for connections to be returned to the pool before proceeding.



4.3.1 Advanced Options

Login Delay - this defaults to zero and should remain at that value. Inserting a value here could cause unnecessary delays.

Test Connections on Reserve - this determines whether connections are tested before being given to a client. Turning on this option will cause your application to run slightly slower, but it will take advantage of WebLogic's automatic testing of connections, so that your application won't need to handle the situation where the connection it gets is not working. Turning off this option will cause your application to run slightly faster, but it will not use WebLogic's automatic testing of connections, so that your application will need to handle the situation where the connection that is obtained from the pool may not work.

Test Table Name - a table the Data Source user has access to which contains a small number of rows. The SQL executed will be: select count(*) from TestTableName

Also note that there is a Monitoring Tab available that can help you track the performance of a data source.




5. Troubleshooting



5.1. Session Defaults Warning

Teradata does not provide any means to "reset" a connection. Therefore, the user of a connection pool data source must avoid using any commands that affect session defaults. Any changes to session defaults will continue to be in effect for the next unsuspecting user of that connection.

Session parameters that must not be changed include:

  • Database (SET SESSION DATABASE command)
  • Collation (SET SESSION COLLATION command)
  • Character Set
  • Transaction Semantics
  • Dateform (SET SESSION DATEFORM command)
  • Timezone (SET TIME ZONE command)
  • Default date format
  • QueryBand (SET QUERY_BAND ... FOR SESSION command, introduced with Teradata Database 12.0)

The SET QUERY_BAND ... FOR TRANSACTION command is recommended as an alternative to SET QUERY_BAND ... FOR SESSION, because SET QUERY_BAND ... FOR TRANSACTION is limited in scope to the current transaction.



5.2. Preparation of CMP Entity Beans for Deployment

To manage transactions correctly for contained-managed persistence (CMP) entity beans, the WebLogic EJB container requires a TXDataSource (not a plain data source) to be specified.

    [WebLogic 8.1]

To configure a new TXDataSource using WebLogic server Admin Console, both the "Honor Global Transactions" checkbox and "Emulate Two-Phase Commit for non-XA Driver" checkbox need to be checked.

    [WebLogic 9.x and WebLogic 10.x]

To configure a new TXDataSource using WebLogic server Admin Console, both the "Supports Global Transactions" checkbox and "Emulate Two-Phase Commit" checkbox need to be checked.




Appendix A: WebLogic Code Samples

Sample code to access a previously created Connection Pool using Data Source default username and password.

import java.sql.*;
import javax.sql.*;
import java.io.*;
import javax.naming.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SampleJdbcServlet extends HttpServlet
{
  public void doGet(HttpServletRequest req,HttpServletResponse res)
    throws ServletException, IOException
  {
    String datasource = req.getParameter("datasource");
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    out.println("<html><body><pre>");
    try
    {
      Context ctx = new InitialContext();

      out.println("Looking up datasource " + datasource);
      DataSource ds = (DataSource) ctx.lookup(datasource);

      out.println("Establishing connection...");
      
      Connection con = ds.getConnection();
      out.println("Connection obtained is: " + con);

      con.close();
      out.println("Connection.isClosed returns: " + con.isClosed());
    }
    catch (SQLException ex)
    {
      out.println("*** SQLException caught ***");
      while (ex != null)
      {
        out.println("Message: " + ex.getMessage ());
        out.println("SQLState: " + ex.getSQLState ());
        out.println("ErrorCode: " + ex.getErrorCode ());
        ex.printStackTrace (out);
        ex = ex.getNextException ();
      }
    }
    catch (java.lang.Exception ex)
    {
      out.println("*** Exception caught ***");
      ex.printStackTrace (out);
    }

    out.println("SampleJdbcServlet finished.");
    out.println("</pre></body></html>");
    out.close();
  }
}



Questions or Feedback
Contact Us
 
Related Resources
Teradata Developer Exchange
Teradata Discussion Forums
White Papers
Teradata Support Services
Teradata User Groups


Find more downloads (including early access and unsupported releases) on Teradata Developer Exchange.
Company Newsroom Site Help Site Map Privacy/Legal Contact Us