Introduction to WebLogic JDBC

The following sections provide an overview of the JDBC components and JDBC API:

 


Overview of JDBC

Java Database Connectivity is a standard Java API that consists of a set of classes and interfaces written in the Java programming language. Application, tool, and database developers use JDBC to write database applications and execute SQL statements.

JDBC is a low-level interface, which means that you use it to invoke (or call) SQL commands directly. In addition, JDBC is a base upon which to build higher-level interfaces and tools, such as Java Message Service and Enterprise Java Beans .

 


Using JDBC Drivers with WebLogic Server

JDBC drivers implement the interfaces and classes of the JDBC API. The following sections describe the JDBC driver options that you can use with WebLogic Server.

 

Types of JDBC Drivers

WebLogic Server uses the following types of JDBC drivers that work in conjunction with each other to provide database access:

  • Standard JDBC drivers that provide database access directly between a WebLogic Server connection pool and the database. WebLogic Server uses a DBMS vendor-specific JDBC driver, such as the WebLogic jDrivers for Oracle and Microsoft SQL Server, to connect to a back-end database.
  • Wrapper drivers that provide vendor-neutral database access. A Java client application can use a wrapper driver to access any database configured in WebLogic server (via a connection pool). BEA offers three wrapper drivers - RMI, Pool, and JTS. The WebLogic Server system uses these drivers behind the scenes when you use a JNDI look-up to get a connection from a connection pool through a data source. A client application can also use these drivers directly to get a connection from a connection pool (You can use RMI from external clients and the pool and JTS from server-side clients only). However, BEA recommends that you use a data source to get a connection from a connection pool, rather than using these drivers directly. (See Obtaining a Client Connection Using a DataSource.)

The middle tier architecture of WebLogic Server, including data sources and connection pools, allows you to manage database resources centrally in WebLogic Server. The vendor-neutral wrapper drivers makes it easier to adapt purchased components to your DBMS environment and to write more portable code.

 

Table of WebLogic Server JDBC Drivers

The following table summarizes the drivers that WebLogic Server uses.

Type and
Name of Driver

Database
Connectivity

Documentation Sources

Type 2 (requires native libraries):

  • WebLogic jDriver for Oracle

  • WebLogic jDriver for Oracle XA

  • Third-party drivers, such as the Oracle OCI driver and the IBM DB2 driver
Between WebLogic Server and DBMS in local and distributed transactions. Programming WebLogic JDBC (this document)Programming WebLogic JTAAdministration Console Online Help, "Configuring JDBC Connection PoolsUsing WebLogic jDriver for Oracle
Type 4 (pure Java)

  • WebLogic jDrivers for Microsoft SQL Server

  • Third-party drivers, including:
    Oracle Thin and Oracle Thin XA drivers
Between WebLogic Server and DBMS in local and distributed transactions.

Note: The WebLogic jDrivers for Microsoft SQL Server supports local transactions only.

Programming WebLogic JDBC (this document)Programming WebLogic JTAAdministration Console Online Help, "Configuring JDBC Connection PoolsUsing WebLogic jDriver for Microsoft SQL Server
Type 3

  • WebLogic RMI Driver
Between an external client and WebLogic Server (connection pool). Programming WebLogic JDBC (this document)

 

WebLogic Server JDBC Drivers

The following sections describe Type 2 and Type 4 JDBC drivers from BEA used with WebLogic Server to connect to the vendor-specific DBMS.

 

WebLogic jDriver for Oracle

BEA's WebLogic jDriver for Oracle is included with the WebLogic Server distribution. This driver requires an Oracle client installation. The WebLogic jDriver for Oracle XA driver extends the WebLogic jDriver for Oracle for distributed transactions. For additional information, see Using WebLogic jDriver for Oracle.

 

BEA WebLogic Type 4 JDBC Driver for Microsoft SQL Servers

WebLogic Server 8.1 SP1 includes a new JDBC driver from BEA for connecting to a Microsoft SQL Server database. The BEA WebLogic Type 4 JDBC MS SQL Server driver replaces the WebLogic jDriver for Microsoft SQL Server, which is deprecated. The new driver offers JDBC 3.0 compliance, support for some JDBC 2.0 extensions, and better performance. BEA recommends that you use the new BEA WebLogic Type 4 JDBC MS SQL Server driver in place of the WebLogic jDriver for Microsoft SQL Server.

For more information, see BEA WebLogic Type 4 JDBC Drivers.

 

WebLogic jDriver for Microsoft SQL Server (Deprecated)

BEA's WebLogic jDriver for Microsoft SQL Server, included in the WebLogic Server distribution, is a pure-Java, Type 4 JDBC driver that provides connectivity to Microsoft SQL Server. For more information, see Configuring and Using WebLogic jDriver for MS SQL Server.

 

WebLogic Server Wrapper Drivers

The following sections briefly describe the WebLogic wrapper drivers that provide database access to applications. You can use these drivers in server-side applications (also in client applications for the RMI driver), however BEA recommends that you look up a data source from the JNDI tree to get a database connection.

For more details about using these drivers, see Using WebLogic Wrapper Drivers.

 

WebLogic RMI Driver

The WebLogic RMI driver is a Type 3 JDBC driver that runs in WebLogic Server. You can use the WebLogic RMI driver in a remote client application to connect to a database through a WebLogic Server connection pool, however, this is not the recommended method. BEA recommends that you look up a data source on the JNDI tree to get a database connection from a connection pool. For requests from external clients, the data source then internally uses the RMI driver, if necessary.

You can use the WebLogic RMI driver with server-side or client applications.

For more details about using the WebLogic RMI driver, see Using the WebLogic RMI Driver.

 

WebLogic Pool Driver

The WebLogic Pool driver enables utilization of connection pools from server-side applications such as HTTP servlets or EJBs. You can use it directly in server-side applications, but BEA recommends that you use a data source through a JNDI look-up to get a connection from a connection pool. Data sources in WebLogic Server use the WebLogic Pool driver internally to get connections from a connection pool.

For information about using the Pool driver, see Accessing Databases in Programming Tasks in Programming WebLogic HTTP Servlets.

 

WebLogic JTS Driver

The WebLogic JTS driver is a wrapper driver that is similar to the WebLogic Pool Driver, but is used in distributed transactions across multiple servers with one database instance. The JTS driver is more efficient than the WebLogic jDriver for Oracle XA driver when working with only one database instance because calls from the transaction manager to start and end work with this branch of the transaction (XAResource.start() and XAResource.end()) do not require communication with the database (they are no-ops).

This driver is for use with server-side applications only.

For more details about using the WebLogic JTS driver, see Using the WebLogic JTS Driver.

 

Third-Party JDBC Drivers

WebLogic Server works with third-party JDBC drivers that meet the following requirements:

  • Are thread-safe.
  • Support the JDBC API. Drivers can support extensions to the API, but they must support the JDBC API as a minimum.
  • Implement EJB transaction calls in JDBC.

You typically use these drivers when configuring WebLogic Server to create physical database connections in a connection pool.

 

Oracle Thin Driver

The Oracle Thin Type 4 driver bundled with WebLogic Server provides connectivity from WebLogic Server to an Oracle DBMS. You may want to use the latest version of the Oracle Thin driver, which is available from the Oracle Web site. For information on using this driver with WebLogic Server, see Using Third-Party Drivers with WebLogic Server.

 


Overview of Connection Pools

In WebLogic Server, you can configure connection pools that provide ready-to-use pools of connections to your DBMS. Client and server-side applications can utilize connections from a connection pool through a DataSource on the JNDI tree (the preferred method) or by using a WebLogic wrapper driver. When finished with a connection, applications return the connection to the connection pool.

Figure 1-1 WebLogic Server Connection Pool Architecture

WebLogic Server Connection Pool Architecture

When the connection pool starts up, it creates a specified number of physical database connections. By establishing connections at start-up, the connection pool eliminates the overhead of creating a database connection for each application.

Connection pools require a JDBC driver to make the physical database connections from WebLogic Server to the DBMS. The JDBC driver can be one of the WebLogic jDrivers or a third-party JDBC driver, such as the Oracle Thin Driver. The following table summarizes the advantages to using connection pools.

Connection Pools Provide These Advantages. . .

With This Functionality . . .

Save time, low overhead Creating a DBMS connection is a slow operation. With connection pools, connections are already established and available to users. The alternative is for applications to make their own JDBC connections as needed. A DBMS runs faster with dedicated connections than if it has to handle incoming connection attempts at run time.
Manage DBMS users Allows you to manage the number of concurrent DBMS connections on your system. This is important if you have a licensing limitation for DBMS connections, or a resource concern.Your application does not need to know of or transmit the DBMS username, password, and DBMS location.
Allow use of the DBMS persistence option If you use the DBMS persistence option with some APIs, such as EJBs, pools are mandatory so that WebLogic Server can control the JDBC connection. This ensures your EJB transactions are committed or rolled back correctly and completely.

This section is an overview of connection pools. For more detailed information, see Configuring and Using Connection Pools.

 

Using Connection Pools with Server-side Applications

For database access from server-side applications, such as HTTP servlets, use a DataSource from the Java Naming and Directory Interface (JNDI) tree or use the WebLogic Pool driver. For distributed transactions, use a TxDataSource from the JNDI tree. For transactions distributed across multiple servers within a single WebLogic domain with one database instance, use a TxDataSource from the JNDI tree or use the JTS driver. Note that BEA recommends that you access connection pools using the JNDI tree and a DataSource object rather than using WebLogic wrapper drivers.

 

Using Connection Pools with Client-side Applications

Note: For new deployments, BEA recommends that you use a DataSource from the JNDI tree to access database connections rather than the RMI driver.

BEA offers the RMI driver for client-side JDBC. The RMI driver provides a standards-based approach using the Java 2 Enterprise Edition (J2EE) specifications.

The WebLogic RMI driver is a Type 3 JDBC driver that uses RMI and a DataSource object to create database connections. This driver also provides for clustered JDBC, leveraging the load balancing and failover features of WebLogic Server clusters. You can define DataSource objects to enable transactional support or not.

 


Overview of MultiPools

JDBC MultiPools are "pools of connection pools" that you can set up according to either a high availability or load balancing algorithm. Use a MultiPool in the same manner that you use a connection pool. When an application requests a connection, the MultiPool determines which connection pool will provide a connection, based on the selected algorithm. MultiPools are not supported with distributed transactions.

You can choose one of the following algorithm options for each MultiPool in your WebLogic Server configuration:

  • High availability, in which the connection pools are set up as an ordered list and used sequentially.
  • Load balancing, in which all listed pools are accessed using a round-robin scheme.

For more information, see Configuring and Using MultiPools.

 


Overview of Clustered JDBC

WebLogic Server allows you to cluster JDBC objects, including data sources, connection pools and MultiPools, to improve the availability of cluster-hosted applications. Each JDBC object you configure for your cluster must exist on each managed server in the cluster - when you configure the JDBC objects, target them to the cluster.

For information about JDBC objects in a clustered environment, see "JDBC Connections in Using WebLogic Server Clusters.

 


Overview of DataSources

Client- and server-side JDBC applications can obtain a DBMS connection using a DataSource. A DataSource is an interface between an application and the connection pool. Each data source (such as a DBMS instance) requires a separate DataSource object, which may be implemented as a DataSource class that supports distributed transactions. For more information, see Configuring and Using DataSources.

 


JDBC API

To create a JDBC application, use the java.sql API to create the class objects necessary to establish a connection with a data source, to send queries and update statements to the data source, and to process the results. For a complete description of all JDBC interfaces, see the standard JDBC interfaces at java.sql Javadoc. See Configuring and Using Connection Pools. Also see the following WebLogic Javadocs:

 


JDBC 2.0

WebLogic Server uses a Java 2 SDK 1.4.1, which supports JDBC 2.0.

 


Platforms

Supported platforms vary by vendor-specific DBMSs and drivers. For current information, see BEA WebLogic Supported Configurations.

Skip navigation bar  Back to Top Previous Next