The examples installed with Oracle WebLogic Server include the Derby "examples" database. The wl_server
examples domain includes JDBC data sources configured to use with the Derby database out-of-the-box. You do not need to configure the database or database connectivity when running the examples in the wl_server
domain. For more information about Derby, see the public ApacheDerby documentation. The information in the following sections can help you configure database connectivity if you want to run the examples from a different domain or if you want to recreate the data in the database.
Prerequisites
Make sure that the Derby server is running and that you have the following information:
-
Database name
-
Host name or IP address
-
Port
-
Database username and password
Derby starts automatically when the examples Server in the wl_server domain is started. Make sure that the Derby server is running. Use the Derby "ij" tool located in the WL_HOME
\common\derby\bin
subdirectory of the WebLogic Server installation directory. If you are running the examples in a different domain, you can manually start the Derby server. See Starting Derby.
Generating Derby Data
Follow these steps to configure Oracle WebLogic Server exampleproperty values and populate the Derby database with sample data:
-
Using a text editor, open the
examples.properties
file, located inthe EXAMPLES_HOME\examples\src
directory, where EXAMPLES_HOME represents the root directory in which the WebLogic Server Examples are configured; for example:C:\Oracle\Middleware\Oracle_Home\wlserver\samples\server
. -
Change the following lines to fit your environment:
-
derby.url=jdbc:derby://localhost:1527/examples;create=true;ServerName=localhost;databaseName=examples
-
derby.username=examples
-
derby.password=examples
Save the file when you are finished.
-
-
Open a command shell and setup the environment.
-
Change to the EXAMPLES_HOME
\examples\src\examples\common\ddl
directory. -
Enter the following command:
ant db.setup.derby
This Ant target creates the tables and inserts sample data.
To use a database server other than Derby, Oracle, or MySQL, create adb.setup.
db_vendor
target in thebuild.xml
file, similar todb.setup.derby
, and set the driver class; URL; and host, username, and password for the server.
Configuring JDBC Data Sources for Derby
Some Oracle WebLogic Server examples use database connections from JDBC data sources configured in the wl_server domain installed with the Oracle WebLogic Server examples. If you want to run an example in a different domain, you may need add one or more of the data sources to your WebLogic domain.
To configure the examples-demo data source:
-
Open the Oracle WebLogic Server Administration Console.
-
In the Domain Structure view in the left pane, expand Services > Data Sources.
-
On the Summary of JDBC Data Sources page, click New.
-
On the JDBC Data Source Properties page,enter or select the following information:
Name - Enter
examples-demo
.JNDI Name - Enter
examples-dataSource-demoPool
.Database Type - Select Derby or the DBMS of the database to which you want to connect. If your DBMS is notlisted, select Other.
Click Next to continue.
Database Driver - Select Derby's Driver (Type 4)Versions: Any or another non-XA JDBC driver that you want to use to connect to the database.
Note: You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with Oracle WebLogic Server, but not all listed drivers are installed. The Derby driver is installed with Oracle WebLogic Server.
Click Next to continue.
-
On the Transactions Options page, follow these steps:
-
Select Supports Global Transactions.
-
Select One-Phase Commit.
Click Next to continue.
-
-
On the Connection Properties page, enter values for the following properties:
Database Name - Enter
demo
or the name of the database to which you want to connect.Host Name - Enter
localhost
or the DNS name or IP address of the server that hosts the database.Port - Enter
1527
for Derby or enter the port on which the database server listens for connections requests.Database User Name - Enter
examples
for the Derby database installed with the Oracle WebLogic Server examples or if you are using a different database, enter the database user account name that you want to use for each connection in the data source.Password / Confirm Password - Enter
examples
for the Derby database or enter the password for the database user acccount specified above.Click Next to continue.
-
On the Test Database Connection page,review the connection parameters and click Test Configuration.
Oracle WebLogic Server attempts to create a connection from the Administration Server to the database. Results from the connection test are displayed at the top of the page. If the test is unsuccessful, you should correct any configuation errors and retry the test.
If the JDBC driver you selected is not installed on the Administration Server, you should click Next to skip this step.
Click Next to continue.
-
On the Select Targets page, select examples Server or select the servers or clusters on which you want to deploy the data source.
-
Click Finish to save the JDBC data source configuration. When your changes are activated, the data source will be deployed to the targets that you selected.
-
To activate these changes, you must restart the server.
To configure the examples-demoXA data source:
-
Open the Administration Console.
-
In the Domain Structure view in the left pane, expand Services > Data Sources.
-
On the Summary of Data Sources page, click New.
-
On the JDBC Data Source Properties page,enter or select the following information:
Name - Enter
examples-demoXA
.JNDI Name - Enter
examples-dataSource-demoXAPool
.Database Type - Select Derby or the DBMS of the database to which you want to connect. If your DBMS is notlisted, select Other.
Click Next to continue.
Database Driver - Select Derby's Driver (Type 4XA) Versions: Any or another XA JDBC driver that you want to use to connect to the database.
Note: You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with Oracle WebLogic Server, but not all listed drivers are installed. The Derby driver is installed with Oracle WebLogic Server.
Click Next to continue.
-
On the Transactions Options page, disable Supports Global Transactions.If the XA JDBC driver you selected requires a global transaction to execute SQL code, skip this step. Click Next to continue.
-
On the Connection Properties page, enter values for the following properties:
Database Name - Enter
demo
or the name of the database to which you want to connect.Host Name - Enter
localhost
or the DNS name or IP address of the server that hosts the database.Port - Enter
1527
for Derby or enter the port on which the database server listens for connections requests.Database User Name - Enter
examples
for the Derby database installed with the Oracle WebLogic Server examples or if you are using a different database, enter the database user account name that you want to use for each connection in the data source.Password/Confirm Password - Enter
examples
for the Derby database or enter the password for the database user acccount specified above.Click Next to continue.
-
On the Test Database Connection page,review the connection parameters and click Test Configuration.
Oracle WebLogic Server attempts to create a connection from the Administration Server to the database. Results from the connection test are displayed at the top of the page. If the test is unsuccessful, you should correct any configuation errors and retry the test.
If the JDBC driver you selected is not installed on the Administration Server, you should click Next to skip this step.
Click Next to continue.
-
On the Select Targets page, select examples Server or select the serversor clusters on which you want to deploy the data source.
-
Click Finish to save the JDBC data source configuration. When your changes are activated, the data source will be deployed to the targets that you selected.
-
To activate these changes, you must restart the server.
To configure the examples-demoXA-2 data source:
-
Open the Administration Console.
-
In the Domain Structure view in the left pane, expand Services > Data Sources.
-
On the Summary of Data Sources page, click New.
-
On the JDBC Data Source Properties page,enter or select the following information:
Name - Enter
examples-demoXA-2
.JNDI Name - Enter
examples-demoXA-2
.Database Type - Select Derby or the DBMS of the database to which you want to connect. If your DBMS is not listed, select Other.
Click Next to continue.
Database Driver - Select Derby's Driver (Type 4XA) Versions: Any or another XA JDBC driver that you want to use to connect to the database.
Note: You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with Oracle WebLogic Server, but not all listed drivers are installed. The Derby driver is installed with Oracle WebLogic Server.
Click Next to continue.
-
On the Transactions Options page, disable Supports Global Transactions.If the XA JDBC driver you selected requires a global transaction to execute SQL code, skip this step. Click Next to continue.
-
On the Connection Properties page, enter values for the following properties:
Database Name - Enter
demo
or the name of the database to which you want to connect.Host Name - Enter
localhost
or the DNS name or IP address of the server that hosts the database.Port - Enter
1527
for Derby or enter the port on which the database server listens for connections requests.Database User Name - Enter
examples
for the Derby database installed with the Oracle WebLogic Server examples or if you are using a different database, enter the database user account name that you want to use for each connectionin the data source.Password/Confirm Password - Enter
examples
for the Derby database or enter the password for the database user account specified above.Click Next to continue.
-
On the Test Database Connection page,review the connection parameters and click Test Configuration.
Oracle WebLogic Server attempts to create a connection from the Administration Server to the database. Results from the connection test are displayed at the top of the page. If the test is unsuccessful, you should correct any configuation errors and retry the test.
If the JDBC driver you selected is not installed on the Administration Server, you should click Next to skip thisstep.
Click Next to continue.
-
On the Select Targets page, select examples Server or select the servers or clusters on which you want to deploy the data source.
-
Click Finish to save the JDBC data source configuration. When your changes are activated, the data source will be deployed to the targets that you selected.
-
To activate these changes, you must restart the server.