CIS355A Week 6 Practice Program – Pizza Data/IO
Introduction – Connecting and Manipulating Databases
This week you’re going to replace the File IO operations your completed last week and replace them with database operations. During this exercise you will see the advantage of making the effort in creating a 3-tiered architecture that encapsulations the operations into the appropriate layer.
Use your OmnyBus MySQL Account
Updating the Pizza Order Program:
Here is what you will need to do to get the Pizza Program to work.
In the OmnyBus EDUPE server management application:
Open the database you created.
Create a table called “PizzaOrder” with the following fields
1) id as an Int, set to primary key, set Autoincrement = yes
2) firstName as a varchar of length 50
3) lastName as a varchar of length 50
4) size of type small int
5) cheese as a tinyint (MySQL boolean)
6) sausage as tinyint
7) ham as a tinyint
8) total as a double
In the Netbeans (or Eclipse) project ensure that the MYSQL jar file is correctly referenced (in your assignments, you will have to move this file into your project and set the path to the jar file):
Right click on the project name, then select “Properities”.
Confirm that the mysql-connector.jar file is listed in the “Compile Time Libaries:”
See the following that demonstrates how to set the driver, jar reference path:
In the Data project, DataIO class update the following constant fields to showy our credential information:
In the DataIO class there are TODO items (select WINDOW|ACTION ITEM to see list of todo, click to take you to the code location). You are then asked to modify the following methods to interact with the database.