BEA Home | Events | Solutions | Partners | Products | Services | Download | Developer Center | WebSUPPORT
| WebLogic Server Doc Home | Programming WebLogic JDBC | Previous Topic | Next Topic | Contents | View as PDF

Introduction to WebLogic JDBC

The following sections introduce the JDBC components and JDBC API:

- Overview of JDBC

- Overview of JDBC Drivers

- Description of JDBC Drivers

- Overview of Connection Pools

- Overview of MultiPools

- Overview of Clustered JDBC

- Overview of DataSources

- JDBC API

- JDBC 2.0

- Platforms

Overview of JDBC

JDBC is a Java API for executing SQL statements. The API consists of a set of classes and interfaces written in the Java programming language. JDBC provides a standard API for tool/database developers and makes it possible to write database applications using a pure Java API.

JDBC is a low-level interface, which means that it is used to invoke (or call) SQL commands directly. In addition, JDBC is a base upon which to build higher-level interfaces and tools, such as JMS and EJB.

Overview of JDBC Drivers

JDBC drivers implement the interfaces and classes of the JDBC API. BEA provides a variety of options for database access using the JDBC API specification. These options include two-tier JDBC drivers, including WebLogic jDrivers for the Oracle, Microsoft SQL Server, and Informix database management systems (DBMS), and multitier drivers that work with WebLogic Server as an intermediary between a client application and the DBMS.

Types of JDBC Drivers

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

- Two-tier drivers that provide database access directly between a java application and the database. WebLogic Server uses a DBMS vendor-specific JDBC driver to connect to a back-end database, such as the WebLogic jDrivers for Oracle, Informix and Microsoft SQL Server.

- Multitier drivers that provide vendor-neutral database access. A Java client application can use a multitier driver to access any database configured in WebLogic server. BEA offers three multitier drivers—RMI, Pool, and JTS.

The middle tier architecture allows you to manage database resources centrally in WebLogic Server. The vendor-neutral multitier JDBC drivers makes it easier to adapt purchased components to your DBMS environment and to write more portable code.

Table of Drivers

The following table summarizes the drivers that WebLogic Server uses.

Table 1-1 JDBC Drivers

Driver Tier | Type and Name of Driver | Database Connectivity | Documentation Sources
--- | --- | --- | ---
Two-tier (non-XA) | Type 2 (native .dll): WebLogic jDriver for Oracle Third-party drivers Type 4 (all Java) WebLogic jDrivers for Informix and Microsoft SQL Server Third-party drivers, including: Oracle Thin Sybase jConnect DB2 Informix JDBC | Between WebLogic Server and DBMS. | Programming WebLogic JDBC (this document) Administration Guide, "Managing JDBC Connectivity" Installing and Using WebLogic jDriver for Oracle Installing and Using WebLogic jDriver for Informix Installing and Using WebLogic jDriver for Microsoft SQL Server
Two-tier (XA) | Type 2 (native .dll) WebLogic jDriver for Oracle XA | Between WebLogic Server and DBMS in distributed transactions. | Programming WebLogic JTA Administration Guide, "Managing JDBC Connectivity"
Multitier | Type 3 RMI Driver Pool Driver JTS | Between client and WebLogic Server. The RMI driver replaces the deprecated t3 driver. The JTS driver is used in distributed transactions. The Pool and JTS drivers are server-side only. | Programming WebLogic JDBC (this document)

Description of JDBC Drivers

The following sections describe in detail the JDBC drivers introduced in Table 1-1 JDBC Drivers.

WebLogic Server JDBC Two-Tier Drivers

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

WebLogic jDriver for Oracle

BEA's Type 2 JDBC driver for Oracle, 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 Installing and Using WebLogic jDriver for Oracle.

WebLogic jDriver for Microsoft SQL Server

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

WebLogic jDriver for Informix

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

WebLogic Server JDBC Multitier Drivers

The following sections describe the WebLogic multitier JDBC drivers that provide database access to the client. For more information on these drivers, see Using WebLogic Multitier Drivers in Programming WebLogic JDBC.

WebLogic Pool Driver

The WebLogic Pool driver enables utilization of connection pools from server-side applications such as HTTP servlets or EJBs.

WebLogic RMI Driver

The WebLogic RMI driver is a multitier, Type 3, Java Data Base Connectivity (JDBC) driver that runs in WebLogic Server and can be used with any two-tier JDBC driver to provide database access. Additionally, when configured in a cluster of WebLogic Servers, the WebLogic RMI driver can be used for clustered JDBC, allowing JDBC clients the benefits of load balancing and failover provided by WebLogic Clusters.

WebLogic JTS Driver

The WebLogic JTS driver is a multitier, Type 3, JDBC driver 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 it avoids two-phase commit.

Third-Party Drivers

WebLogic Server works with third-party JDBC drivers that offer the following functionality:

- Are thread-safe

- Are EJB accessible; can implement transaction calls in JDBC

In addition, WebLogic Server multitier drivers only support JDBC API and third-party drivers that provide functionality beyond non-standard JDBC calls.

Cloudscape

An evaluation copy of this pure-Java DBMS from Cloudscape is included with your WebLogic Server distribution. A JDBC driver to access the Cloudscape DBMS is also included. This DBMS is used extensively in the code examples that are also included in the distribution. You may use this DBMS for testing and development if you do not have another DBMS available. There are limitations on the quantity of data that may be stored using this evaluation version.

For additional information, see Using the Cloudscape Database with WebLogic.

Sybase jConnect Driver

The two-tier Sybase jConnect Type 4 driver is bundled with your WebLogic Server distribution. This driver is provided for your use without charge. For information on using this driver with WebLogic Server, see Using Third-Party Drivers with WebLogic Server.

Oracle Thin Driver

The two-tier Oracle Thin Type 4 driver provides connectivity from WebLogic Server to Oracle DBMS. For information on using this driver with WebLogic Server, see Using Third-Party Drivers with WebLogic Server.

Overview of Connection Pools

Multitier drivers use WebLogic Server to access connection pools that provide ready-to-use pools of connections to your DBMS. Since these database connections are already established when the connection pool starts up, the overhead of establishing database connections is eliminated. You can utilize connection pools from server-side applications such as HTTP servlets or EJBs using the WebLogic Pool driver or from stand-alone Java client applications using the WebLogic RMI driver. This section provides an introduction to connection pools. For more detailed information, see Using Connection Pools.

Connection pools require a two-tier JDBC driver to make the connection from WebLogic Server to the DBMS. This two-tier driver can be one of the WebLogic jDrivers or a third-party JDBC driver, such as the Sybase jConnect driver, which is bundled with the WebLogic distribution. The following table summarizes the advantages to using connection pools.

Table 1-2 Advantages to Using Connection Pools

Connection Pools Provide These Advantages. . . | With This Functionality . . .
--- | ---
Save time, low overhead | Making a DBMS connection is very slow. With connection pools, connections are established and available to users. The alternative is for application code to make its 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 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 like EJBs, pools are mandatory so WebLogic Server controls the JDBC connection. This ensures your EJB transactions are committed or rolled back correctly and completely.

Using Connection Pools with Server-side Applications

For database access from server-side applications, such as HTTP servlets, use the WebLogic Pool driver. For two-phase commit transactions, use the WebLogic Server JDBC/XA driver, WebLogic jDriver for Oracle/XA. For transactions distributed across multiple servers with one database instance, use the JTS driver. You can also access connection pools using the Java Naming and Directory Interface (JNDI) and a DataSource object.

Using Connection Pools with Client-side Applications

BEA offers the RMI driver for client-side, multitier JDBC. The RMI driver has the advantage of providing a standards-based approach using the Java 2 Enterprise Edition (J2EE) specifications. For new deployments, BEA recommends that you use the RMI driver, because the t3 client services are deprecated in this release.

The WebLogic RMI driver is a Type 3, multitier 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 Clusters. DataSource objects may be defined to enable transactional support or not.

Overview of MultiPools

JDBC MultiPools provide the option of choosing either the high availability or load balancing algorithm to enhance database connectivity. MultiPools are a "pool of pools" that allow a configurable algorithm for choosing among its list of pools, the pool that will be selected to provide the connection. For more information, see Using MultiPools.

Choosing the MultiPool Algorithm

You have the option of setting up a MultiPool in either of these ways:

- 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.

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 more information about JDBC objects in a cluster, see "JDBC Connections" in Using WebLogic Server Clusters.

Overview of DataSources

DataSource objects provide a way for JDBC clients to obtain a DBMS connection. A DataSource is an interface between the client program and the connection pool. Each data source requires a separate DataSource object, which may be implemented as a DataSource class that supports either connection pooling or distributed transactions. For more information, see Configuring and Using DataSources.

JDBC API

To create a JDBC application, use the java.sql API. The API allows you to create the class objects necessary to establish a connection with a data source, send queries and update statements to the data source, and process the results.

WebLogic JDBC Interface Definitions

The following table lists JDBC interfaces frequently used with WebLogic Server. For a complete description of all JDBC interfaces, see the java.sql or weblogic.jdbc Javadoc.

JDBC Interface | Description
--- | ---
Driver | Sets up a connection between a driver and a database, and also gives information about the driver or information about making a connection to the database.The interface that every driver class must implement.
DataSource | Represents a particular DBMS or other data source. Used to establish a connection with a data source.
Statement | Sends simple SQL statements, with no parameters, to a database.
PreparedStatement | Inherits from Statement. Used to execute a pre-compiled SQL statement with or without IN parameters.
CallableStatement | Inherits from PreparedStatement. Used to execute a call to a database stored procedure; adds methods for dealing with OUT parameters.
ResultSet | Contains the results of executing an SQL query. It contains the rows that satisfy the conditions of the query.
ResultSetMetaData | Provides information about the types and properties of the columns in a ResultSet object.
DataBaseMetaData | Provides information about a database as a whole. Returns either single values or a result set.
Clob | A built-in type that stores a Character Large Object as a column value in a row of a database table.
Blob | A built-in type that stores a Binary Large Object as a column value in a row of a database table.

For information about these interfaces when using WebLogic jDriver for Oracle, see Installing and Using WebLogic jDriver for Oracle .

JDBC 2.0

WebLogic Server uses JDK 1.3, which supports JDBC 2.0.

Limitations

Please be aware of the following limitations:

- You cannot use Batch updates (addBatch()) with the callableStatement or preparedStatement SQL statements when using the RMI driver in conjunction with the WebLogic jDriver for Oracle or third-party 2-Tier drivers.

Platforms

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

Copyright © 2001 BEA Systems, Inc. All rights reserved. Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.