bea.com | products | dev2dev | support | askBEA |
|
e-docs > WebLogic Server > Administration Console Online Help > JDBC DataSources |
Administration Console Online Help |
A Data Source object enables JDBC applications to obtain a DBMS connection from a connection pool. Each Data Source object binds to the JNDI tree and points to a connection pool or MultiPool. Applications look up the Data Source on the JNDI tree and then request a connection from the Data Source. Data Source objects can be defined with support for global transactions (enables support for JTA). Support for global transactions is required if your applications use distributed transactions. See When to Enable Global Transactions in a Data Source for more information about using Data Sources and transaction-enabled Data Sources.
When to Enable Global Transactions in a Data Source
If your applications or environment meet any of the following criteria, you should enable global transactions in the Data Source (select Honor Global Transactions during configuration). This is equivalent to using a Tx Data Source in previous releases of WebLogic Server.
When not to enable global transactions:
With an EJB architecture, it is common for multiple EJBs that are doing database work to be invoked as part of a single transaction. Without XA, the only way for this to work is if all transaction participants use the exact same database connection. WebLogic Server uses the JTS driver and a TxDataSource to do this behind the scenes without requiring you to explicitly pass the JDBC connection from EJB to EJB. With XA (requires an XA driver), you can use a Tx Data Source in WebLogic Server for distributed transactions with two-phase commit so that EJBs can use a different database connection for each part of the transaction. In either case (with or without XA), you should use a Tx Data Source (a data source with Honor Global Transactions selected).
Read more about Data Sources in Programming WebLogic JDBC.
If you need to support distributed transactions with a JDBC connection pool, but there is no available XA-compliant driver for your DBMS, you can select the Emulate Two-Phase Commit for non-XA Driver option for a data source to emulate two-phase commit for the transactions in which the connection pool participates. This option is an advanced option on the Data Source
When you enable the Emulate Two-Phase Commit for non-XA Driver option, The WebLogic server Transaction Manager allows the non-XA resource to enlist in the transaction as the last agent in the transaction. At the end of the Prepare phase of the two-phase commit process, the Transaction Manager issues the commit message (one-phase) to the non-XA resource first. The result of the commit operation on the non-XA resource determines the message to send during the second phase of the transaction, commit or rollback, and determines the outcome of the transaction. XA participants are informed of the outcome in the second phase of the 2PC protocol as usual. See Configuring Non-XA JDBC Drivers for Distributed Transactions for more information.
Note: There are risks to data integrity when using the Emulate Two-Phase Commit for non-XA Driver option. BEA recommends that you use an XA-compliant JDBC driver rather than use this option. Make sure you consider the risks below before enabling this option.
Consider the following limitations and risks before using the Emulate Two-Phase Commit for non-XA Driver option.
Use the Emulate Two-Phase Commit for non-XA Driver option if the JDBC connection is the only non-XA participant in the transaction and there is no XA compliant JDBC driver available. With more than one non-XA resource participating in a transaction and more than one of the non-XA resources are emulating an XA resource, you may see heuristic failures.
If the DataSource is associated with a connection pool that uses an XA-compliant JDBC driver, or if there is only one resource participating in the distributed transaction, then this setting is ignored.
When you use the Emulate Two-Phase Commit for non-XA Driver option, the non-XA participant does not completely participate in the two-phase commit process. During the commit phase, it is possible for server or network failures to cause heuristic completions and possible data inconsistencies. Because the WebLogic Server Transaction Manager presumes abort on resource or communication failure, a network failure after the commit message was sent to a remote non-XA resource will likely cause a heuristic completion: the Transaction Manager will send a roll back message to the XA resources after losing contact with the remote resource, which cannot roll back after committing the changes.
Because of the data integrity risks, the Emulate Two-Phase Commit for non-XA Driver option should only be used in applications that can tolerate heuristic conditions.
Creating and Configuring a JDBC Data Source
Name—Enter a name for this JDBC data source. This name is used in the configuration file (config.xml) and throughout the Administration Console whenever referring to this data source.
JNDI Name—Enter the JNDI path to where this JDBC data source will be bound.
Honor Global Transactions—Select this check box (the default) to enable global transactions using this data source. Clear this check box to disable (ignore) global transactions using this data source. In most cases, you should leave the option selected. See When to Enable Global Transactions in a Data Source.
Note: You must specify a new JNDI Name for the new data source. The new data source cannot use the same JNDI Name as the original data source.
For more information about the attributes on the Configuration tab, see Attributes.
Deploying a JDBC Data Source to a Server or Cluster
Adding a Note to a Data Source
In WebLogic Server, you can bind a JDBC DataSource resource into the WebLogic Server JNDI tree as a resource factory. You can then map a resource factory reference in the EJB deployment descriptor to an available resource factory in a running WebLogic Server to get a connection from a connection pool.
For details about creating and using a JDBC Data Source factory, see Resource Factories in Programming WebLogic Enterprise JavaBeans.
Creating and Configuring a JDBC Data Source Factory
There are no monitoring options for data sources in WebLogic Server. However, you can monitor connection pools and transactions. See the following sections for more information:
Monitoring a JDBC Connection Pool