| products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 

WebLogic Server Frequently Asked Questions

 Previous Next Contents View as PDF  

FAQs: WebLogic JDBC

Q. When should I use a TxDataSource instead of a DataSource?

A. If your applications or environment meet any of the following criteria, you should use a Tx Data Source instead of a Data Source:

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 (with Emulate Two-Phase Commit for non-XA Driver selected) 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 connections for each part of the transaction. In either case (with or without XA), you should use a Tx Data Source.

Q. When should I use MultiPools?

A. If you are using WebLogic Server in a single-server configuration, you can use MultiPools in one of two ways 1) for high availability in the event a database connection fails, or 2) for load balancing MultiPool. Because you can choose only one option, you need to determine the primary purpose of your MultiPool. For more information, see Using Multipools in the Configuring and Administering WebLogic JDBC Features section of Programming WebLogic JDBC.

Q. How can I tell if a database is unavailable?

A. Fundamentally, there is no way to tell if a database has gone down except by trying to make a connection and failing.

Furthermore, a database can become unavailable at any time after you make and use a connection. We recommend that you write your code to be able to handle unexpected failures, which can come in any form depending on what the client is doing when the database goes down.

WebLogic Server does provide the dbping utility to test the connection between WebLogic Server and your DBMS using a JDBC driver. See dbping in "Using the WebLogic Java Utilities" in the WebLogic Server Command Reference.


Back to Top Previous Next