In the first part of this homework assignment, I will walk you through some commands to
In the second part, we will link that SQL table together with your Java Servlet and JSP code from Beer-v1, to make an application called BeerDB-v1. (We'll also rename other parts of the servlet and JSP code to ensure they stay separate from Beer-v1.)
In the third part, you will use what you have learned do something similar for your Prod-v1 application, creating a ProdDB-v1 application.
The ProdDB-v1 is the part you will turn in for credit. You should script and submit that in a similar fashion to what you did for H02 (see H02 for detailed submission requirements), except that you should also include in your printout, a sample session using /jaguar/cisc474/mysql/bin/mysql, where you list out the tables, columns, and rows you created.
Due: H03a part only: Tuesday, March 22nd (hopefully finished today) |
Useful links:
MySQL Documentation: http://dev.mysql.com/doc/mysql/en/index.html
Your username for your MySQL account will be the same as your strauss username.
Your password will be given to you in class.
First change, your password as follows:
jaguar>
/jaguar/cisc474/mysql/bin/mysql -u username -p
Enter password:
jaguar> /jaguar/cisc474/mysql/bin/mysql -u username -p
Enter password: xxxxxxx
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19 to server version: 4.1.10-standard-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
The original Beer-v1 app returned
We are going to be a bit more sophisticated (though not much.) We want to create a table with two columns, as follows:
name | color |
---|---|
Jack Amber | amber |
Red Moose | amber |
Jail Pale Ale | light |
Gout Stout | dark |
Notice that the colors in the Beer-v1 app are amber, light, dark, and brown. I've deliberately put nothing in the table for Brown, so that we can learn how to handle the case of "no results being returned" from a SQL query.
Next step is to create the table.
Useful links:
Here's an example:
jaguar[136] > /jaguar/cisc474/mysql/bin/mysql -u pconrad -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 20 to server version: 4.1.10-standard-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +----------+ | Database | +----------+ | pconrad | | test | +----------+ 2 rows in set (0.01 sec) mysql> use pconrad; Database changed mysql> create table beer (name char(20), color char(10)); Query OK, 0 rows affected (0.02 sec) mysql>
Useful links:
mysql> insert into beer (name, color) values ('Jack Amber','amber'); Query OK, 1 row affected (0.00 sec) mysql> insert into beer (name, color) values ('Red Moose','amber'); Query OK, 1 row affected (0.00 sec) mysql> insert into beer (name, color) values ('Jail Pale Ale','light'); Query OK, 1 row affected (0.00 sec) mysql> insert into beer (name, color) values ('Gout Stout','dark'); Query OK, 1 row affected (0.04 sec) mysql> select name, color from beer; +---------------+-------+ | name | color | +---------------+-------+ | Jack Amber | amber | | Red Moose | amber | | Jail Pale Ale | light | | Gout Stout | dark | +---------------+-------+ 4 rows in set (0.05 sec) mysql>
Ok, now we've got a table. We just need to get to it from our servlet. That will be the next assignment.