12 WebLogic Server JDBC Data Sources
Applications look up the data source on the JNDI tree or in the local application context and then reserve a database connection with the getConnection
method. Data sources and their connection pools provide connection management processes that help keep your system running efficiently.
This chapter includes the following sections:
Create JDBC data sources
You must create a data source for each database to which you want to connect. If you need more than one set of configuration options for a database, then you can create more than one data source that includes connections to the same database. This section includes the following tasks:
- Create JDBC generic data sources
- Create JDBC GridLink data sources
- Create JDBC multi data sources
- Create JDBC UCP data sources
- Create a JDBC data source from an existing data source
Parent topic: WebLogic Server JDBC Data Sources
Create JDBC generic data sources
Before you begin
Make sure that the JDBC drivers that you want to use to create database connections are installed on all server instances on which you want to deploy the data source. Some JDBC drivers are installed with WebLogic Server, including Oracle Type 4 JDBC drivers for DB2, Informix, MS SQL Server, and Sybase.
For more information about working with JDBC drivers, see Using JDBC Drivers with WebLogic Server.
To create a JDBC generic data source:
Parent topic: Create JDBC data sources
Data Source Properties
On the Data Sources Properties page, define the general configuration options for this JDBC data source.
-
Data Source Name: enter a name for this JDBC data source. This name is used in the configuration file (
config.xml
) and whenever referring to this data source. -
Scope: select the scope in which you want to create this JDBC data source.
-
Driver Class Name: select the JDBC driver you want to use to connect to the database. The list includes common JDBC drivers for the selected DBMS.
Note:
You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with WebLogic Server, but many are not installed.
-
JNDI Name: enter the JNDI path to where this JDBC data source will be bound. Applications look up the data source on the JNDI tree by this name when reserving a connection.
-
Row Prefetch Enabled: select to enable multiple rows to be "prefetched" (that is, sent from the server to the client) in one server access.
-
Row Prefetch Size: if you enabled row prefetching, specify the number of result set rows to prefetch for a client.
-
Stream Chunk Size: specify the data chunk size for steaming data types.
Parent topic: Create JDBC generic data sources
Transaction Properties
On the Transaction Properties page, follow these steps. Depending on the driver you selected on the JDBC Data Source Properties page, you may not need to specify any of these options.
Supports Global Transactions: select this check box (the default) to enable global transaction support in this data source. Clear this check box to disable (ignore) global transactions in this data source. In most cases, you should leave the option selected.
If you selected Supports Global Transactions, then select an option for transaction processing (available options vary depending on whether you select an XA driver or a non-XA driver):
-
One-Phase Commit: select this option to enable the non-XA connection to participate in a global transaction as the only transaction participant. This option is only available when you select a non-XA JDBC driver to make database connections.
-
Emulate Two-Phase Commit: enables a non-XA JDBC connection to emulate participation in distributed transactions using JTA. Select this option only if your application can tolerate heuristic conditions. This option is only available when you select a non-XA JDBC driver to make database connections.
-
Logging Last Resource: select this option to enable a non-XA JDBC connection to participate in global transactions using the Logging Last Resource (LLR) transaction optimization. Recommended in place of Emulate Two-Phase Commit. This option is only available when you select a non-XA JDBC driver to make database connections.
Parent topic: Create JDBC generic data sources
Select Targets
On the Select Targets page, select the server instances and clusters on which you want to deploy the data source.
Parent topic: Create JDBC generic data sources
Review
On the Review page, review the configuration for this JDBC data source.
Parent topic: Create JDBC generic data sources
Create JDBC GridLink data sources
Configure database connectivity with your Oracle RAC installation by adding a JDBC GridLink data source to your WebLogic Server domain. Data sources and their connection pools provide connection management processes that help keep your system running efficiently.
To create a JDBC GridLink data source:
- Data Source Properties
- Connection Properties
- Transaction Properties
- ONS Properties
- Select Targets
- Review
Parent topic: Create JDBC data sources
Data Source Properties
On the Data Sources Properties page, define the general configuration options for this JDBC data source.
-
Data Source Name: enter a name for this JDBC data source. This name is used in the configuration file (
config.xml
) and whenever referring to this data source. -
Scope: select the scope in which you want to create this JDBC data source.
-
Driver Class Name: select the JDBC driver you want to use to connect to the database. The list includes common JDBC drivers for the selected DBMS.
Note:
You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with WebLogic Server, but many are not installed.
-
JNDI Name: enter the JNDI path to where this JDBC data source will be bound. Applications look up the data source on the JNDI tree by this name when reserving a connection.
-
Row Prefetch Enabled: select to enable multiple rows to be "prefetched" (that is, sent from the server to the client) in one server access.
-
Row Prefetch Size: if you enabled row prefetching, specify the number of result set rows to prefetch for a client.
-
Stream Chunk Size: specify the data chunk size for steaming data types.
Parent topic: Create JDBC GridLink data sources
Transaction Properties
On the Transaction Properties page, follow these steps. Depending on the driver you selected on the JDBC Data Source Properties page, you may not need to specify any of these options.
Supports Global Transactions: select this check box (the default) to enable global transaction support in this data source. Clear this check box to disable (ignore) global transactions in this data source. In most cases, you should leave the option selected.
If you selected Supports Global Transactions, then select an option for transaction processing (available options vary depending on whether you select an XA driver or a non-XA driver):
-
One-Phase Commit: select this option to enable the non-XA connection to participate in a global transaction as the only transaction participant. This option is only available when you select a non-XA JDBC driver to make database connections.
-
Emulate Two-Phase Commit: enables a non-XA JDBC connection to emulate participation in distributed transactions using JTA. Select this option only if your application can tolerate heuristic conditions. This option is only available when you select a non-XA JDBC driver to make database connections.
-
Logging Last Resource: select this option to enable a non-XA JDBC connection to participate in global transactions using the Logging Last Resource (LLR) transaction optimization. Recommended in place of Emulate Two-Phase Commit. This option is only available when you select a non-XA JDBC driver to make database connections.
Parent topic: Create JDBC GridLink data sources
ONS Properties
On the ONS Properties page, enter values for the following properties:
-
Select Fan Enabled to subscribe to Oracle Fan Events.
-
Under ONS Nodes, click Add and enter the ONS host and port for each ONS node.
-
To test individual nodes, click Test ONS Node for an ONS host and port.
-
Optionally, configure an ONS wallet file if you want ONS to use SSL protocol.
Parent topic: Create JDBC GridLink data sources
Select Targets
On the Select Targets page, select the server instances and clusters on which you want to deploy the data source.
Parent topic: Create JDBC GridLink data sources
Review
On the Review page, review the configuration for this JDBC GridLink data source.
Parent topic: Create JDBC GridLink data sources
Create JDBC multi data sources
Multi data sources provide failover and load balancing for connection requests between two or more data sources. Before you create a multi data source, you should create the data sources that the multi data source will manage, and deploy them to the same targets to which you want to deploy the multi data source.
To create a JDBC multi data source:
Parent topic: Create JDBC data sources
Configure Data Source Properties
On the Configure Data Sources Properties page, define the general configuration options for this JDBC multi data source.
-
Data Source Name: enter a name for this JDBC multi data source. This name is used in the configuration files (
config.xml
and the JDBC module) and whenever referring to this multi data source. -
Scope: select the scope in which you want to create this JDBC data source.
-
JNDI Name: enter the JNDI path to where this JDBC multi data source will be bound. Applications look up the data source on the JNDI tree by this name when reserving a connection.
-
Algorithm Type: select an algorithm option:
-
Failover: The multi data source routes connection requests to the first data source in the list; if the request fails, the request is sent to the next data source in the list, and so forth.
-
Load-Balancing: The multi data source distributes connection requests evenly to its member data sources.
-
Parent topic: Create JDBC multi data sources
Select Targets
On the Select Targets page, select the server instances or clusters on which you want to deploy this JDBC multi data source.
The targets you select will limit the data sources that you can select as part of the multi data source. You can only select data sources that are deployed to the same targets as the multi data source.
Parent topic: Create JDBC multi data sources
Select Data Source Type
On the Select Data Source Type page, select one of the following options:
-
XA Driver: The multi data source will only use data sources that use an XA JDBC driver to create database connections.
-
Non-XA Driver: The multi data source will only use data sources that use a non-XA JDBC driver to create database connections.
The option you select limits the data sources that you can select as part of the multi data source in a later step. Limiting data sources by JDBC driver type enables the WebLogic Server transaction manager to properly complete or recover global transactions that use a database connection from a multi data source.
Parent topic: Create JDBC multi data sources
Add Data Sources
On the Add Data Sources page, select the data sources that you want the multi data source to use to satisfy connection requests.
Parent topic: Create JDBC multi data sources
Review
On the Review page, review the configuration for this JDBC multi data source.
Parent topic: Create JDBC multi data sources
Create JDBC UCP data sources
To create a JDBC UCP data source:
Parent topic: Create JDBC data sources
Data Source Properties
On the Data Sources Properties page, define the general configuration options for this UCP data source.
-
Data Source Name: enter a name for this JDBC data source. This name is used in the configuration file (
config.xml
) and whenever referring to this data source. -
Scope: select the scope in which you want to create this JDBC data source.
Note:
The scope defaults to
Global
for the domain level. -
Driver Class Name: select the JDBC driver you want to use to connect to the database. The list includes common JDBC drivers for the selected DBMS.
Note:
You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with WebLogic Server, but many are not installed.
-
JNDI Name: enter the JNDI path to where this JDBC data source will be bound. Applications look up the data source on the JNDI tree by this name when reserving a connection.
For more information on these fields, see Configuration Options.
Parent topic: Create JDBC UCP data sources
Select Targets
On the Select Targets page, select the server instances and clusters on which you want to deploy the data source.
Parent topic: Create JDBC UCP data sources
Review
On the Review page, review the configuration for this JDBC UCP data source.
Parent topic: Create JDBC UCP data sources
Create a JDBC data source from an existing data source
You can create a new JDBC data source to have the same configuration settings as an existing JDBC data source.
To create a new JDBC data source from an existing JDBC data source:
Parent topic: Create JDBC data sources
Monitor JDBC data sources
After you create a JDBC data source, you can monitor it to look for unusual activity, such as an abnormal number of requests waiting for a connection. You can also test the connection between a data source and the database. This section includes the following tasks:
- Monitor JDBC data sources
- Monitor a JDBC data source
- Monitor a JDBC GridLink data source
- Monitor a JDBC multi data source
- Test JDBC data sources
Parent topic: WebLogic Server JDBC Data Sources
Monitor JDBC data sources
You can monitor a variety of statistics for each data source instance in your domain, such as the current number of database connections in the connection pool, current number of connections in use, the longest wait time for a database connection, and so forth.
To monitor the activity of the JDBC data source instances deployed to the current domain:
Parent topic: Monitor JDBC data sources
Monitor a JDBC data source
To monitor the activity of a specific JDBC data source instance deployed to the current domain:
Parent topic: Monitor JDBC data sources
Monitor a JDBC GridLink data source
To monitor the activity of a specific JDBC GridLink data source instance deployed to the current domain:
Parent topic: Monitor JDBC data sources
Monitor a JDBC multi data source
To monitor the activity of a specific JDBC multi data source instance deployed to the current domain:
Parent topic: Monitor JDBC data sources
Test JDBC data sources
You can manually test individual instances of a data source. When you test a data source, WebLogic Server reserves a connection from the data source, tests it using the standard testing query or the query specified in Test Table Name, and then returns the database connection to the pool of connections. Test results are displayed at the top of the page.
The manual connection test relies on the Test Reserved Connections and Test Table Name attributes of the data source. Those attributes are set by default. However, if you changed either attribute, the changes will affect the database connection test.
To test a JDBC data source:
- From the WebLogic Domain menu, select JDBC Data Sources.
- In the JDBC Data Sources table, select the JDBC data source you want to monitor.
- Select Monitoring.
- Click Test Data Source. Test results are displayed.
Parent topic: Monitor JDBC data sources
Control JDBC data sources
After you create a JDBC data source, you can perform administrative tasks on instances of the data source, including resetting all database connections, suspending use of the data source, and shutting down the data source. This section includes the following tasks:
- Start JDBC data sources
- Stop JDBC data sources
- Resume suspended JDBC data sources
- Suspend JDBC data sources
- Shrink JDBC data source connection pools
- Reset JDBC data source connections
- Clear JDBC data source statement caches
- Delete JDBC data sources
- Control a JDBC data source
- Control a JDBC multi data source
Parent topic: WebLogic Server JDBC Data Sources
Start JDBC data sources
You can manually start data source instances that have a health state of Shutdown
.
To start a JDBC data source:
Parent topic: Control JDBC data sources
Stop JDBC data sources
You can manually stop individual instances of a data source. When you stop a data source, behavior depends on the type of stop that you select:
-
Stop: shuts down a data source that has a health state of
Running
. If any connections from the data source are currently in use, then theShutdown
operation fails and the health state remainsRunning
. -
Force Stop: shuts down a data source that has a health state of
Running
, including forcing the disconnection of all current connection users.
To stop a JDBC data source:
Parent topic: Control JDBC data sources
Resume suspended JDBC data sources
You can manually resume data source instances that are in a Suspended
state.
To resume a suspended JDBC data source:
Parent topic: Control JDBC data sources
Suspend JDBC data sources
You can manually suspend individual instances of a data source. When you suspend a data source, applications can no longer get a database connection from the data source. For connections that are already reserved by an application, behavior depends on the type of suspension that you select:
-
Suspend: marks the data source as disabled and blocks any new connection requests. If there are any reserved connections, then the operation will wait for
InactiveTimeout
seconds, if configured. Otherwise, the operation waits 60 seconds before suspending all connections. If successful, then the health state is set toSuspended
. -
Force Suspend: marks the data source as disabled, blocks any new requests for a connection from the connection pool, and closes and recreates connections currently in use.
Most connections in a suspended data source remain intact. The connections are not recreated when you resume the data source, except for the connections in use when the data source is Force Suspended.
To suspend a JDBC data source:
Parent topic: Control JDBC data sources
Shrink JDBC data source connection pools
You can manually shrink the pool of database connections in individual instances of a data source to the initial capacity or the current number of connections in use, whichever is greater.
To shrink the connection pool in a JDBC data source:
Parent topic: Control JDBC data sources
Reset JDBC data source connections
When you reset the database connections in a JDBC data source, WebLogic Server closes and recreates all available database connections in the pool of connections in the data source.
To reset database connections in a JDBC data source:
Parent topic: Control JDBC data sources
Clear JDBC data source statement caches
If statement caching is enabled for a data source, then WebLogic Server caches are prepared and callable statements that are used in each connection in the data source. Each connection has its own cache, but the caches for each connection are configured and managed as a group. When you clear the statement cache for a data source, you clear the statement cache for all connections in the instance of the data source you select.
See Increasing Performance with the Statement Cache.
To clear the statement cache in a JDBC data source:
Parent topic: Control JDBC data sources
Delete JDBC data sources
Before you begin
Ensure that the data source you want to delete is not used by a multi data source. If the data source you want to delete is used by a multi data source, then you must remove the data source from the multi data source before the data source can be deleted. The delete operation will fail if the data source you are attempting to delete is used by a multi data source.
To delete a JDBC data source:
Parent topic: Control JDBC data sources
Control a JDBC data source
To control a specific JDBC data source instance deployed to the current domain:
Parent topic: Control JDBC data sources
Control a JDBC multi data source
To control a specific JDBC multi data source instance deployed to the current domain:
Parent topic: Control JDBC data sources
Configure JDBC data sources
When you create a JDBC data source, most data source attributes are configured so that the data source will work in your environment. However, you may need to modify a data source configuration to enable or disable specific features or to tune performance.
This section includes the following tasks:
- Define general configuration settings
- Configure connection pool properties
- Configure Oracle parameters
- Configure ONS client parameters
- Configure global transaction options
- Configure JDBC data source diagnostic profiling
- Configure JDBC data source identity options
- Target JDBC data sources
- Configure tags for a JDBC data source
- Create JDBC data sources notes
- Configure a JDBC multi data source
Parent topic: WebLogic Server JDBC Data Sources
Define general configuration settings
Applications connect to databases from a data source by looking up the data source on the Java Naming and Directory Interface (JNDI) tree and then requesting a connection. The data source provides the connection to the application from its pool of data base connections.
To define general configuration settings for a specific JDBC data source:
After you finish
After you activate your changes, you will need to redeploy the data source or restart your server before the changes will take effect.
Parent topic: Configure JDBC data sources
Bind a JDBC data source to the JNDI tree with multiple names
Before you begin
You can configure a data source so that it binds to the JNDI tree with multiple names. You can use a multi-JNDI-named data source in place of legacy configurations that included multiple data sources that pointed to a single JDBC connection pool. You must either restart the system after making your change or undeploy the data source before making the change, and then redeploy it after making the change.
To add JNDI names to an existing JDBC data source:
After you finish
After you activate your changes, you will need to redeploy the data source or restart your server before the changes will take effect.
Parent topic: Define general configuration settings
Configure connection pool properties
The connection pool within a JDBC data source contains a group of JDBC connections that applications reserve, use, and then return to the pool. The connection pool and the connections within it are created when the connection pool is registered, usually when starting WebLogic Server or when deploying the data source to a new target.
To configure the connection pool for a specific JDBC data source:
- Configure JDBC data source testing options
- Configure statement cache
- Configure connection pool capacity
- Enable connection requests to wait for a connection
Parent topic: Configure JDBC data sources
Configure JDBC data source testing options
You can set database connection testing options in a data source to make sure that the database connections remain healthy, which helps keep your applications running properly.
To configure testing options for a JDBC data source:
Parent topic: Configure connection pool properties
Configure statement cache
To improve performance, WebLogic Server can cache prepared and callable statements used in your applications (enabled by default). When an application or EJB calls any of the statements stored in the cache, WebLogic Server reuses the statement stored in the cache. Each database connection in a data source has its own statement cache.
To configure the statement cache for a JDBC data source:
Parent topic: Configure connection pool properties
Configure connection pool capacity
You can configure the initial and maximum capacity for a JDBC connection pool.
To configure the connection capacity for a JDBC connection pool:
Parent topic: Configure connection pool properties
Enable connection requests to wait for a connection
To enable connection requests to wait for a connection from a JDBC data source:
Parent topic: Configure connection pool properties
Configure Oracle parameters
Before you begin
Additional configuration may be required to support Oracle parameters.
See Using Active GridLink Data Sources in Administering JDBC Data Sources for Oracle WebLogic Server.
To configure Oracle parameters:
Parent topic: Configure JDBC data sources
Configure ONS client parameters
Before you begin
Additional configuration may be required to support ONS client parameters.
See Using Active GridLink Data Sources in Administering JDBC Data Sources for Oracle WebLogic Server.
To configure ONS client parameters:
Parent topic: Configure JDBC data sources
Configure SSL for the ONS client using a Oracle wallet file
Before you begin
A wallet file is only required when the ONS client is configured to communicate with ONS daemons using SSL. Additional configuration is required to support this feature.
See Using GridLink Data Sources in Administering JDBC Data Sources for Oracle WebLogic Server.
To configure an Oracle wallet file when using SSL:
Parent topic: Configure ONS client parameters
Configure global transaction options
The transaction protocol for a JDBC data source determines how connections from the data source are handled during transaction processing.
See JDBC Data Source Transaction Options in Administering JDBC Data Sources for Oracle WebLogic Server.
Note:
If the data source uses an XA JDBC driver to create database connections, then connections from the data source will support the two-phase commit transaction protocol only. No other transaction options are available for data sources that use an XA JDBC driver.
To configure transaction options for a JDBC data source:
Parent topic: Configure JDBC data sources
Configure JDBC data source diagnostic profiling
If the monitoring statistics indicate that there is a problem in your WebLogic Server domain, then you can configure any data source to collect profile information to help you pinpoint the source of the problem. The collected profile information is stored in records in the WLDF Archive.
To configure diagnostic profiling for a JDBC data source:
Parent topic: Configure JDBC data sources
Configure JDBC data source identity options
You can choose the security option you want to use when mapping WebLogic Server user credentials to database user credentials. This section includes the following tasks:
Parent topic: Configure JDBC data sources
Enable credential mapping
When an application requests a database connection from the data source, WebLogic Server determines the current WebLogic Server user ID and then sets the mapped database ID as a lightweight client ID on the database connection.
Note:
This feature relies on features in the JDBC driver and DBMS. It is only supported for use with Oracle and DB2 databases and with the Oracle Thin and DB2 UDB JDBC drivers, respectively.
To enable credential mapping for a JDBC data source:
Parent topic: Configure JDBC data source identity options
Enable identity-based connection pooling
Identity-based connection pooling allows applications to use a JDBC connection with a specific DBMS credential based on the end user application by pooling physical connections.
To enable identity-based connection pooling for a JDBC data source:
Parent topic: Configure JDBC data source identity options
Target JDBC data sources
Before you begin
Ensure that the JDBC drivers you want to use to create database connections are installed on all server instances on which you want to deploy the data source. Some JDBC drivers are installed with WebLogic Server, including WebLogic Type 4 JDBC drivers for DB2, Informix, MS SQL Server, and Sybase.
For more information about working with JDBC drivers, see Using JDBC Drivers with WebLogic Server.
When you target a JDBC data source, a new instance of the data source is created on the target. When you select a server as a target, an instance of the data source is created on the server. When you select a cluster as a target, an instance of the data source is created on all member server instances in the cluster.
To target a JDBC data source:
- From the WebLogic Domain menu, select JDBC Data Sources.
- In the JDBC Data Sources table, select the JDBC data source you want to target.
- Select Targets.
- On the Targets page, select the server instances or clusters on which you want to deploy the data source.
- Click Save to save the JDBC data source configuration and deploy the data source to the targets that you selected.
Parent topic: Configure JDBC data sources
Configure tags for a JDBC data source
To configure tags for a specific JDBC data source:
Parent topic: Configure JDBC data sources
Create JDBC data sources notes
To create notes for JDBC data source configuration:
- From the WebLogic Domain menu, select JDBC Data Sources.
- In the JDBC Data Sources table, select the JDBC data source for which you want to create notes.
- Select Notes.
- On the Notes page, enter your notes.
- Click Save.
Parent topic: Configure JDBC data sources
Configure a JDBC multi data source
Multi data sources provide failover and load balancing for connection requests between two or more data sources. Before you create a multi data source, you should create the data sources that the multi data source will manage, and deploy them to same targets on which you want to deploy the multi data source. Note that the underlying databases must have some kind of data synchronization or replication. WebLogic Server does not handle that replication.
To configure a specific JDBC multi data source:
Parent topic: Configure JDBC data sources