|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON J2EE Configuring BEA WebLogic 8.1 JDBC Connectivity
WebLogic 8.1 JDBC configuration with an Oracle 8.1.7 database
By: Deepak Vohra; Ajay Vohra
Jan. 9, 2004 12:00 AM
This article describes the configuration of various JDBC-related features in the BEA WebLogic 8.1 Server. Although we use Oracle 8.1.7 as our example database management system (DBMS), the general concepts are easily transferable to other relational databases as long as the databases in question provide connectivity through JDBC. Introduction Connection Pool or Multi Pool? If you didn't use a JDBC connection pool for access to a database, in order to establish a connection to a database you would need to follow these steps:
A multi pool is a collection of connection pools. The main purpose for multi pools is to increase availability and load balancing across a set of connection pools. Why a Data Source? A data source encapsulates access to a database and hides the details involved in accessing a connection pool or a multi pool. In addition, a data source makes it easy to configure the transactional nature of a database connection. A JDBC Data Source Factory is a JNDI object used by an enterprise application to get a connection from an application-scoped connection pool. JDBC Drivers Setup The WebLogic 8.1 Server is installed in the <WEBLOGIC> directory. The Oracle 8.1.7 database is installed in the <ORACLE> directory. <PATH> is the WebLogic Server Path variable. For both Type 2 and Type 4 drivers, relevant JDBC driver classes are required in the WebLogic Server CLASSPATH to configure a connection pool or a data source. Add the <ORACLE>\JDBC\lib\classes12.zip file containing the Oracle Type 2 JDBC driver classes to the <CLASSPATH> variable in the <domain>/startWebLogic script file.
Now we'll look at how to create a connection pool and configure the various parameters associated with a it. To create a JDBC connection pool, right-click on the JDBC>Connection Pools node in the Administration Console and select "Configure a new JDBC Connection Pool". A Configure a JDBC Connection Pool frame is displayed. Select a Database Type - Oracle for an Oracle database. Select a Database Driver and click the Continue button (see Figure 1).
![]() A Define Connection Properties frame is displayed. In the frame, specify a Database Name, a Database User Name, and a Password. Click on the Continue button. A Test DataBase Connection is displayed. In the frame, specify values for the Driver Classname, URL, and Properties fields. Driver Classname is the class name of the driver used to get a database connection. URL is the database URL used to get a connection. Properties is the list of properties to create a connection. The Driver Classname and URL settings for the different Oracle JDBC drivers are specified in Table 1.
![]() In the URL setting, <host> is the HOST value specified in the <ORACLE>/network/ADMIN/tnsnames.ora file, <port> is the PORT value specified in the tnsnames.ora file, and <database> is the database instance name. In the Properties text box the settings are: user=<user> <user> is the user name specified to log in to the Oracle database. <database> is the Oracle database instance name. The server property should not be specified if an Oracle thin (Type 4) driver is used. Click the Test Driver Configuration button to test the JDBC Connection Pool. If the driver configuration test is successful a "Connection successful" message is displayed. If the driver configuration has an error, an error message is displayed. A Create and Deploy frame is displayed. In the frame, select a server to deploy the connection pool, and click the Create and Deploy button to create and deploy a JDBC connection pool. A connection pool is created and deployed on the selected server. It may be deployed on more than one server. A <JDBCConnection Pool> node is added to the JDBC>Connection Pools node in the Administration Console. <JDBCConnection Pool> is the connection pool name. To modify the JDBC Connection Pool configuration, click on the JDBC>Connection Pools><JDBCConnection Pool> node and select the Configuration tab. To modify the target server select the Target and Deploy tab. Select a target server and click the Apply button. Select the Connections tab to configure the JDBC Connections properties. Connection Properties
Configuring a JDBC Multi Pool A Configuration frame is displayed. In the Multi Pool Configuration frame specify Algorithm Type and select the Create button. If Algorithm Type is set to "High availability", all available connections in one pool are used before connections in another pool are used. If Algorithm Type is set to "Load balancing", the multi pool distributes connection requests evenly to all the connection pools in the multi pool (see Figure 2).
![]() Select the Pools tab and in the Pools frame select Connection Pools to be added to the Multi Pool. Click the Apply button. The selected connection pools are added to the multi pool. The connection pool used in a connection is selected based on the Algorithm Type. Select the Target and Deploy tab and in the Target and Deploy frame select a target server. Click the Apply button. A multi pool may be deployed on more than one server. A <Multi Pool> node is added to the JDBC>Multi Pools node in the Administration Console. <Multi Pool> is the multi pool name. Configuring a JDBC Data Source To create and configure a data source right-click on the JDBC>Data Sources node in the Administration Console and select Configure a new JDBCTxData Source. A Configuration frame is displayed. Specify the field settings in the Data Source Configuration frame. JNDI Name is the JNDI path of the Data Source. Select Honor Global Transactions to create a transactional (Tx) Data Source. If Honor Global Transactions is not selected, the data source created is a non-Tx data source (see Figure 3).
![]() A Connect to Connection Pool frame is displayed. In the Pool Name field select a JDBC Connection Pool from the available list of connection pools and click the Continue button. The data source is connected with the selected connection pool. A Target the Data Source frame is displayed. In the frame select a target server and click the Continue button. The data source is deployed on the selected server but may be deployed on more than one server. A <JDBCData Source> node is added to the JDBC>Data Sources node in the Administration Console. <JDBCData Source> is the data source name. To modify the data source configuration, click on the JDBC>Data Sources><JDBCData Source> node in the administration console. Select the Configuration tab. To enable fetching of multiple rows for each Result Set from the server to an external client in one server access, select Row Prefetch Enabled and specify a Row Prefetch Size. To enable global transactions for a non-XA JDBC driver, select Emulate Two-Phase Commit for non-XA Driver, and select Honor Global Transactions. To modify the target server for the data source select the Target and Deploy tab. Select a target server and click the Apply button. Comparison of Data Source and Tx Data Source Tx Data Source should be used instead of a data source for:
A JDBC Data Source Factory is a JNDI data source resource. A Data Source Factory is used by an enterprise application to get connections from an application-scoped connection pool. To create and configure a JDBC Data Source factory, right-click on the JDBC>Data Source Factories node in the Administration Console and select Configure a new JDBCDataSourceFactory. A Configuration frame is displayed. In this frame specify values for the URL, Driver Class Name, Factory Name, and Properties fields and click on the Create button (see Figure 4).
![]() A <JDBCData Source Factory> node is added to the JDBC>Data Source Factories node in the Administration Console. <JDBCData Source Factory> is the Data Source Factory name. To use the <JDBCData Source Factory>, restart the server. JDBC Configuration and Server Performance To enhance server performance in production mode:
Following the procedures outlined here, a WebLogic developer should be able to configure a BEA WebLogic 8.1 Server with an Oracle 8.1 database. Configuring other databases would be similar to Oracle 8.1 Add the zip/jar file containing the driver classes for the corresponding database to the CLASSPATH variable, and specify the corresponding connection URL and driver classname in the JDBC Connection Pool configuration. Resources BEA WEBLOGIC LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||