Building and deploying the application is very easy. We assume that you already have your system configured with a Java SDK version 1.4 or later and also that you already have Apache Ant installed. You can download the source code for the sample application from the "Download Code" section of the Wrox "Programmer to Programmer" website located at www.wrox.com. Just unzip the downloaded archive in a location of your choice.
You will also need to download a recent production release of the MySQL Connector/J JDBC driver from the MySQL website located at www.mysql.com. Unzip the downloaded archive and copy the JAR file named mysql-connector-java-x.x.xx-xxxx.jar (the exact name will vary depending on the downloaded version) to the lib yesdirectory in the directory where you have unzipped the sample application.
We are assuming that you have created the spring database following the preceding instructions. To create the tables we need to run the sample application, copy the create-ticket-mysql.sql file from the db directory of the sample application, and download to the directory where you have MySQL installed. Now you can run the following command:
Windows: bin\mysql -u spring -p spring < create-ticket-mysql.sql Linux: ./bin/mysql -u spring -p spring < create-ticket-mysql.sql
You will be prompted for the password for the "spring" user — it was earlier set to be "t1cket". After this script completes, you can perform the same procedure for load-ticket-mysql.sql. This script file will load the necessary test data. There is also a clear-ticket-mysql.sql to delete the test data and a drop-ticket-mysql.sql script for dropping all the tables.
The build script that we are using is a standard build.xml script. To build the application, change to the directory where you have unpacked the downloaded sample code. Then simply run ant build.
There is another Ant target named "warfile" that will build the application and pack everything into a WAR file located in the dist directory. This WAR file can be deployed directly in your application server. For Tomcat, simply copy this file to the webapps directory that is part of your Tomcat install. When Tomcat is started, you should be able to open http://localhost:8080/ticket in your web browser.