Home

JSP and Beyond

a pragmatic primer on building web-based solutions with Java technologies


Database Script for Sample

For the reference application database we are using MySQL. You can download a copy at http://dev.mysql.com/downloads/. For the purpose of the sample application, I have kept the database very straightforward, only using two tables – one for customer information and the other to hold notes that you will want to append to the customer accounts. The following code will reproduce the database within MySQL.

– MySQL Administrator dump 1.4

– ——————————————————
– Server version 5.0.19-nt

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’NO_AUTO_VALUE_ON_ZERO’ */;


– Create schema DatabaseName

CREATE DATABASE /*!32312 IF NOT EXISTS*/ DatabaseName;
USE DatabaseName;


– Table structure for table `DatabaseName`.`tblcustomer`

DROP TABLE IF EXISTS `tblcustomer`;
CREATE TABLE `tblcustomer` (
`CustomerID` int(10) unsigned NOT NULL auto_increment,
`CustomerName` varchar(255) NOT NULL default ”,
`CustomerType` int(10) unsigned NOT NULL default ‘1′,
PRIMARY KEY (`CustomerID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


– Dumping data for table `DatabaseName`.`tblcustomer`

/*!40000 ALTER TABLE `tblcustomer` DISABLE KEYS */;
/*!40000 ALTER TABLE `tblcustomer` ENABLE KEYS */;


– Table structure for table `DatabaseName`.`tblnote`

DROP TABLE IF EXISTS `tblnote`;
CREATE TABLE `tblnote` (
`NoteID` int(10) unsigned NOT NULL auto_increment,
`Note` varchar(500) NOT NULL default ”,
`CustomerID` int(10) unsigned NOT NULL default ‘0′,
`DateAdded` datetime NOT NULL default ‘0000-00-00 00:00:00′,
PRIMARY KEY (`NoteID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


– Dumping data for table `DatabaseName`.`tblnote`

/*!40000 ALTER TABLE `tblnote` DISABLE KEYS */;
/*!40000 ALTER TABLE `tblnote` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;