| JavaTM Adventure Builder Reference application - Version 1.0.4 > Using MySql |
This document assumes that you have downloaded and installed the J2EE 1.4 Platform Edition. Download the J2EE 1.4 Platform Edition from http://java.sun.com/j2ee/1.4/download.html.
This document only explains how to setup the Adventure Builder Consumer Web Site application of to use MySql as the database. The EJB components in the Order Processing Center use Container Managed Persistence (CMP) which require XA compatible drivers to function correctly. While some solutions using MySql may support CMP with some tuning or driver wrappers we will not focus on that in this example. MySql is a viable open source solution for providing data base support in web applications. The Adventure Builder Consumer Web Site which does not require XA support. The EJB components in the Order Processing Center use derby as the persistence layer which is managed by the container.
1. Download MySql
Download MySql from http://www.mysql.com. version 4.0 is used in this example.
2. Start MySql
This will differ by the platform you use. Please follow the instructions for the target platform.
Unix:
/usr/local/mysql/bin/
On Windows:
C:\mysql\bin
From the command prompt type:
>mysql --user=root --password=yourrootpassword
a. Create the adventurebuilder database:
mysql> create database adventurebuilder;
You should see:
Query OK, 1 row affected (0.00 sec)
b. Create the adventurebuilder user:
Note: Assuming that the MySql database and J2EE server are running on the same machine.
mysql> grant all privileges on adventurebuilder.* to 'adventurebuilder'@'localhost' identified by 'adventurebuilder';
You should see:
Query OK, 0 rows affected (0.10 sec)
c. Commit the changes
mysql> flush privileges;
4. Test the adventurebuilder user:
mysql --user=adventurebuilder --password=adventurebuilder --database=adventurebuilder
5. Check that the tables got created
From the mysql prompt type:
mysql> connect adventurebuilder
You should see:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Connection id: 35
Current database: adventurebuilder
From the mysql prompt type:
mysql> show tables;
You should see:
+----------------------------+
| Tables_in_adventurebuilder |
+----------------------------+
| account |
| activity |
| activitylist |
| category |
| lodging |
| package |
| signon |
| transportation |
+----------------------------+
8 rows in set (0.00 sec)
6. Configure the J2EE server and populate the database
Note: If you have a custom setup of MySql or if you are deploying with different usernames or databases than those specified you will need to modify the setup-mysql.properties file located in the WORKSPACE_HOME/setup/mysql directory.
Run the ant script in this directory to create the necessary JDBC database pool as well as JDBC connection.
To do from the WORKSPACE_HOME/setup/mysql directory type:
>ant
Your J2EE environment should be ready for deployment.
7. Download and Install the Connector/J JDBC Driver
Download the driver from:http://dev.mysql.com/downloads/connector/j/3.1/html
This example uses the Connector/J 3.1 Developer Release
Put the driver jar file in the application server classpath.
For more information see Integrating a JDBC Driver documentation for more details.
8.Deploy Adventure Builder Reference demo applications
Build or Deploy the Adventure Builder application. If you have not deployed the Adventure Builder Reference demo applications you will need to deploy them if you do not want to see an error on the last screen. Adventure Builder requires the support applications to do the order processing.
From the WORKSPACE_HOME/ws directory type:
ant deploy-apps (or asant deploy-apps)
9. View the Adventure Builder Reference demo
View http://localhost:8080/ab.