This section contains information on the following subjects:
WebLogic Event Server supports Java Database Connectivity (JDBC) 3.0 for relational database access.
The
JDBC API provides a standard, vendor-neutral mechanism for connecting to and interacting with database servers and other types of tabular resources that support the API. The JDBC javax.sql.DataSource
interface specifies a database connection factory that is implemented by a driver. Instances of DataSource
objects are used by applications to obtain database connections (instances of java.sql.Connection
). After obtaining a connection, an application interacts with the resource by sending SQL commands and receiving results.
WebLogic Event Server provides the following JDBC drivers, installed in the WLEVS_HOME
/bin
directory, where WLEVS_HOME
refers to the main installation directory such as d:\beahome\wlevs20
.
WebLogic Event Server also provides a DataSource
abstraction that encapsulates a JDBC driver DataSource
object and manages a pool of pre-established connections.
WebLogic Event Server DataSource
provides a JDBC data source connection pooling implementation that supports the Java Database Connectivity (JDBC 3.0) specification. Applications reserve and release Connection
objects from a data source using the standard DataSource.getConnection
and Connection.close
APIs respectively.
You are required to configure a WebLogic Event Server DataSource
in the server's config.xml
file if you want to access a relational database from an EPL rule
; for details, see
Configuring the Complex Event Processor. You do not have to configure a DataSource in the server's config.xml
file if you use the JDBC driver's API, such as DriverManager
, directly in your application code.
The WebLogic Event Server config.xml
file requires a configuration element for each data source that is to be created at runtime that references an external JDBC module descriptor. Following is a sample datasource config.xml
section that illustrates the configuration format.
<data-source>
<name>oraxads2</name>
<driver-params>
<url>jdbc:oracle:thin:@buckhorn.bea.com:1521:ce102a</url>
<driver-name>oracle.jdbc.xa.client.OracleXADataSource</driver-name>
<properties>
<element>
<name>user</name>
<value>cedeployqa</value>
</element>
<element>
<name>password</name>
<value>cedeployqa123</value>
</element>
</properties>
<use-xa-data-source-interface>true</use-xa-data-source-interface>
</driver-params>
<connection-pool-params>
<initial-capacity>15</initial-capacity>
<max-capacity>50</max-capacity>
<test-table-name>SQL SELECT 1 FROM DUAL</test-table-name>
</connection-pool-params>
<data-source-params>
<jndi-names>
<element>oraxads2</element>
</jndi-names>
<global-transactions-protocol>TwoPhaseCommit</global-transactions-protocol>
</data-source-params>
</data-source>
<transaction-manager>
<name>tm1</name>
<rmi-service-name>RMI</rmi-service-name>
</transaction-manager>
A data source depends on the availability of a local transaction manager, which you configure using the <transaction-manager>
element of config.xml
as shown above. The transaction manager in turn depends on a configured RMI object, as described in rmi Configuration Object.
Follow these steps to configure and use JDBC in your application:
The name of the server start script is startwlevs.cmd
(Windows) or startwlevs.sh
(UNIX), and the script is located in the main domain directory. The out-of-the-box sample domains are located in WLEVS_HOME
/samples/domains
, and the user domains are located in BEA_HOME
/user_projects/domains
, where WLEVS_HOME
refers to the main WebLogic Event Server installation directory, such as d:\beahome\wlevs20
, and BEA_HOME
refers to the directory above WLEVS_HOME
, such as d:\beahome
.
Update the start script by adding the -Xbootclasspath/a
option to the Java command that executes the wlevs_2.0.jar
file. Set the -Xbootclasspath/a
option to the full pathname of the JDBC driver you are going to use.
For example, if you want to use the Windows Oracle thin driver, update the java
command in the start script as follows (updated section shown in bold):
%JAVA_HOME%\bin\java -Dwlevs.home=%USER_INSTALL_DIR% -Dbea.home=%BEA_HOME% -Xbootclasspath/a:%USER_INSTALL_DIR%\bin\com.bea.oracle.ojdbc14_10.2.0.jar
-jar "%USER_INSTALL_DIR%\bin\wlevs_2.0.jar" -disablesecurity %1 %2 %3 %4 %5 %6
In the example, %USER_INSTALL_DIR%
points to WLEVS_HOME
.
DataSource
, configure the data source in the server’s config.xml
file.For details, see Data Source Configuration.
java
option. See
Stopping and Starting the Server.