A Connection Pool is created via the graphical interface of the administrative server.
Use the Desktop "Start" button as follows:
Start → Programs → IBM WebSphere → Application Server v6 → Profiles → default → Administrative console
Under "Resources", Click "JDBC Providers" in the left pane.
Press "New" in the right pane.
In the next Window, select "User Defined" from the list of "select Database type" in the right pane and click "Next".
Now the Driver must be configured as shown below.
The required configuration information is listed in the following table.
Field |
Value |
Example |
Name |
The name of the driver. This is user-defined. | Teradata Driver |
Description |
User-defined. | Teradata JDBC |
Classpath |
The full path name of the jar file(s) that make up the
Teradata JDBC Driver. The example assumes that
you have copied these file(s) to the
C:\TeraJDBC directory on your system.
A path on a Linux or UNIX machine would use forward slashes to separate its components. Beginning with Teradata JDBC Driver 16.20.00.11, tdgssconfig.jar is no longer used.
With older versions of the Teradata JDBC Driver, your classpath must also include tdgssconfig.jar .
|
C:\TeraJDBC\terajdbc4.jar
|
Implementation Classname |
The name of the Teradata JDBC Driver data source class. |
com.teradata.jdbc.TeraConnectionPoolDataSource
|
Press "OK" to submit the changes.
Note that "TeradataDriver" will now appear in the list of JDBC Providers. To create a data source, click "TeradataDriver".
The following figure shows how to create a Data Source.
Click "New" in the "Data Sources" pane. Next, the connection pool is defined.
Note: A version 4.x Data Source can also be configured. The required fields are a subset of version 5.x and so are not listed here. The "Database name", "Default User Id" and "Default User password" of a version 4.x data source will override any values defined as custom properties.
Configure the Data Source by entering the data as shown in the figure below.
The required configuration information is listed in the following table.
Field |
Value |
Example |
Name |
The user-defined display name for this resource. | Teradata |
JNDI Name |
User-defined JNDI name of the DataSource. | jdbc/teradata4 |
Container Managed Persistence |
Set if Data Source will be used for CMP of EJBs. | Check this box if the Data Source will be used with CMP entity beans. Otherwise, leave it unchecked. |
Data store helper class |
Data store helper classes provided by WebSphere | Select the option "Generic data store helper". |
After the configuration information is filled in, click "OK".
Now, under "Additional Properties" in the right pane, click "Custom Properties".
The following figure shows how to set the custom properties of the Data Source such as user name, password and data source name.
Click "New" to create a custom property for each of the values shown in the table below. All of this data is defined by the user.
Note: The "Database name", "Default User Id" and "Default User password" of a version 4.x data source will override any values defined as custom properties
Name |
Description |
Value |
DSName |
The hostname of the database. | whomooz |
user |
The database username. | guest |
password |
The password. | please |
In addition to the above parameters, all of the parameters that can be specified in a Teradata JDBC connection URL can also be specified here.
Click "Save" to save your changes. The connection can be tested by selecting the data source and clicking "Test Connection" as shown in the figure below. Please note that the values shown above specify a specific account on a specific database. You will need to modify the value portion of these properties to match the database you are accessing.
You should see a message similar to "Test Connection for datasource Teradata on server server1 at node CHARLIE was successful."
A Java servlet can access a data source to get pooled connections.
With WebSphere, a JDBC Provider is defined to specify information about the JDBC driver. After the JDBC Provider has been defined, then one or more Data Sources can be configured for the JDBC Provider. After each Data Source has been defined, Custom Properties can be configured for each Data Source.
The Data Source's "user" and "password" Custom Properties are optional.
In other words, user and password values must be specified either as Custom Properties, or as arguments to DataSource.getConnection(username,password), or both; and when both are specified, then the arguments to DataSource.getConnection(username,password) override the "user" and "password" Custom Properties defined for a Data Source.
A SQLException will be thrown if user and password values are not specified in either Custom Properties, or as arguments to DataSource.getConnection(username,password).
The exception will differ depending on the combination of Teradata JDBC Driver version and database release.
[Teradata JDBC Driver] : Single Sign-On NOT supported for Mechanism TD2.
HY000
1032
[Teradata Database] : User identification is not authorized.
08004
3004
A SQLException will be thrown if user and password values are specified, but the specified user or password are invalid. Note that invalid user and password values specified as arguments to DataSource.getConnection(username,password) will override correct user and password values specified in Custom Properties. When DataSource.getConnection(username,password) is called but authentication fails, WebSphere does not "fallback" to use the values specified in Custom Properties.
The exception will differ depending on the combination of Teradata JDBC Driver version and database release.
[Teradata Database] : Invalid password.
28000
3003
[Teradata Database] : User identification is not authorized.
08004
3004
The servlet is accessed via a URL similar to the following:
http://server/servlet/servletname
In the example, the username, password and datasource name are all specified in the URL parameters:
http://charlie/servlet/SampleJdbcServlet?user=guest&password=please&datasource=jdbc/teradata4
Note that user-defined variables are in italics.
String user = req.getParameter("user");
String password = req.getParameter("password");
String datasource = req.getParameter("datasource");
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/" + datasource);
Connection con = ds.getConnection(user, password);
At this point, the connection obtained behaves the same way as one obtained from the Driver Manager.
Complete sample servlets are listed here.
Additional configuration is required when WebSphere Java 2 security is enforced.
How to use the Teradata JDBC Driver with WebSphere Java2 Security
After a DataSource has been selected and its properties have been displayed, select "Connection Pool" in the "Additional Properties" panel. This will display the values for properties such as "Connection Timeout", "Max Connections" etc.
Max Connections - too small of a value here can cause users of the pool to waste time waiting for someone to release a connection.
On the page where these values are set, the help text, which can be displayed by clicking the "[i]" box at the right of value, will provide detailed information on the settings and information on how these settings can impact performance.