





















































(For more resources on Oracle, see here.)
In the following sections, we will learn how to set up the environment.
First, download and install the following required products; when installing the MySQL database, select the option to add the MySQL bin directory to the Windows system PATH environment variable:
Next, create a database table in the MySQL database as follows:
>mysql
mysql>use test
CREATE TABLE Catalog (id INT PRIMARY KEY NOT NULL,
journal VARCHAR(100), publisher VARCHAR(100), date VARCHAR(100),
title VARCHAR(100), author VARCHAR(100));
The output from the CREATE TABLE SQL script is shown in the following screenshot:
The table description may be listed with the desc command, as shown in the following illustration:
We shall be using a MySQL database for persistence. Therefore, we need to create a data source in WebLogic Server. Start the WebLogic Server and log in to the Administration Console.
Select the base_domain | Services | JDBC | Data Sources. Click on New in the Data Sources table. Specify a data source name and a JNDI Name (jdbc/MySQLDS) for the data source. Select Database Type as MySQL and Database Driver as MySQL's Driver (Type 4): com.mysql.jdbc.Driver. Click on Next, as shown in the following screenshot:
(Move the mouse over the image to enlarge.)
In the Transaction Options window, select Supports Global Transactions and One-Phase Commit. Click on Next, as shown in the following screenshot:
Specify the connection properties: Database Name as test, Host Name as localhost, Port as 3306, and Database User Name as root. Specify the Password used when installing MySQL and click on Next, as shown in the following screenshot:
In the Test Database Connection window, the Driver Class Name and connection URL are specified, normally filled from the information you entered in the previous screen. Click on Test Configuration to test the connection. Click on Finish, as shown in the following screenshot:
A data source gets added to the Data Sources table with its data source JNDI Name as jdbc/MySQLDS, as shown in the following screenshot:
Next, we deploy the data source to a target server. Click on the data source link in the Data Sources table and select the Targets tab. Select the AdminServer checkbox and click on Save, as shown in the following screenshot:
The target server changes get applied and saved:
To test the data source, click on Test Data Source. If the data source tests without an error, a message indicating the same gets displayed as shown next: