This document explains the steps required to use the DataDirect Connect® for JDBC® drivers with the WebLogic Application Server1. These steps include:
- Install DataDirect Connect for JDBC.
- Create a connection pool using the WebLogic Server Administration Console
- Create a data source using the Administration Console.
- Generate the JSP test page. A sample JSP test page is provided in the WebLogicTest.war file, which is available with this document.
- Deploy the WebLogic web application to the WebLogic server.
- Run the WebLogic web application.
Detailed information about each of these steps is included in the following sections.
You must create a data source to use with the DataDirect Connect for JDBC drivers. An application does not use a connection pool directly to obtain a connection to a database. Instead, an application uses a JDBC data source to obtain a connection from a connection pool.
Creating a Data Source
To create a data source that points to an existing connection pool, complete the following steps:
- Ensure that WebLogic Server is running by executing the startup script you modified in section "1. Install DataDirect Connect® for JDBC." Open the WebLogic Server Console by specifying the URL http://localhost:7001/console in a Web browser.5 Enter the administrator user name and password, and click Sign In.
- In the left pane of the WebLogic Server Console window, select mydomain6 | Services | JDBC | Data Sources. The right pane displays an option that allows you to configure a new JDBC data source as shown in the following example.
- In the right pane, click the Configure a new JDBC Data Source link. The Configure a JDBC Data Source window appears in the right pane.
- In the Name field, enter the name of the data source. In the JNDI Name field, enter the Java Naming Directory Interface (JNDI) name to which the JDBC data source will be bound as shown in the following example. The JNDI name is used by an application to retrieve an instance of the data source from the JNDI.
- Click Continue. The Connect to connection pool window appears. In the Pool Name drop-down box, select the connection pool with which to associate your new data source. For example, to create the following example, you would select the MSSQLServerConnectionPool connection pool that was created in section "2. Create a Connection Pool."
- Click Continue. The Target the data source window appears. Select the server and clusters where the data source will be deployed. Click Create. The new data source is added to the list of data sources as shown in the following example.
An application can obtain connections from a Connection Pool by performing a JNDI lookup for the data source associated with the connection pool. The application uses the JNDI name specified for the data source when it was created to perform the lookup.
A sample JSP test page named WebLogicTest.jsp is contained in the WebLogicTest.war file, which is available with this document. The WebLogicTest.jsp page, contained in the WebLogicTest.war file, includes the following code to look up the data source and obtain a connection to the database from the data source.
InitialContext ctxt = new InitialContext ();
DataSource ds =
(DataSource)ctxt.lookup("("jdbc/MSSQLServer");
con = ds.getConnection ();
- Ensure WebLogic Server is running by executing the startup script you modified in section "1. Install DataDirect Connect® for JDBC."
- Enter the URL http://localhost:7001/WebLogicTest/WebLogicTest.jsp9 in your Web browser to display the WebLogicTest page.
- If the DataDirect Connect for JDBC driver has been installed and configured correctly, the contents of the page display the version information of the driver and the database server to which it connects. For example, the following figure shows version information for the DataDirect Connect for JDBC SQL Server driver connecting to a database server running Microsoft SQL Server 2000.
1 The steps in this document were generated using WebLogic version 8.1. These steps may vary for other versions of WebLogic.
2 The directory examples shown in this document are on Windows.
3 If the server is not running on the local machine, substitute localhost:7001 with the actual hostname and port of the WebLogic Server.
4 mydomain is the default name assigned to a new domain. If a name other than the default was specified when creating the domain, replace mydomain with the actual name of the domain.
5 If the server is not running on the local machine, substitute localhost:7001 with the actual hostname and port of the WebLogic Server.
6 mydomain is the default name given to a new domain. If a name other than the default was specified when creating the domain, replace mydomain with the actual name of the domain.
7 Substitute localhost:7001 with the actual hostname and port of the WebLogic Server if the server is not running on the local machine.
8 mydomain is the default name given to a new domain. If a name other than the default was specified when creating the domain, replace mydomain with the actual name of the domain.
9 If the server is not running on the local machine, substitute localhost:7001 with the actual hostname and port of the WebLogic Server.