Due Monday, Feb. 22, on Gradescope.
1. XML. Read the tutorial linked from the class web page. Find
the error in $cs636/campus.xml and describe it. Hint: try to
display it in a browser. Fix the error and show a snippet of XML
around your fix in your homework paper.
2. Pizza1 on pe07. Command line development, environment
variables, UNIX case.
a. Set up your Linux account at cs.umb.edu as specified in DatabaseSetup,
which also covers setting up environment variable definitions (both at
cs.umb.edu and on your home machine) for ORACLE_USER, ORACLE_PW,
ORACLE_SITE, MYSQL_USER, MYSQL_PW, and MYSQL_SITE. Give the UNIX/Linux
command to recursively copy $cs636/pizza1 to your own pizza1 directory
under your cs636 directory. Do the copy.
b. Cd to the pizza1/database directory and use runH2Script.sh
createdb.sql
to load the H2 tables, and
runH2Script.sh
showdb.sql
to display them. Similarly for Oracle
and mysql, as detailed in the README in the database directory. The
Oracle and mysql cases depend on the environment variables you set up.
Report "success" or description of problems.
c. After loading the database, try runOnH2.sh SystemTest
to
see it run the pizza1 system test. Similarly, using the ORACLE_
environment variables you set up, try runOnOracle SystemTest
.
Also try runOnMysql SystemTest
. Also try TakeOrder
and ShopAdmin using at least H2 .Report "success" or description of
problems.
3 a. Pizza1 at home. Make sure your environment variables
ORACLE_USER, ORACLE_PW, etc., are set up on your development system as
shown in DatabaseSetup, Set up tunnels
for the Oracle and mysql ports. Download pizza1.zip to your home machine
and unzip it there to a convenient directory. Show the whole directory
structure of pizza1 after “mvn clean” and then after "mvn package" while
cd'd to your copy of pizza1, both on cs.umb and at home. I'd use
du for this on UNIX/Linux/mac, tree on PC.
b. Cd to the pizza1/database directory and use runH2Script
createdb.sql
on Windows (or runH2Script.sh createdb.sql
on Mac/Linux) to load the tables into H2, and runH2Script
showdb.sql
or ant show-h2
to display them. Do the
corresponding commands for that database. Note that you do not need to
be logged into pe07 to do this. You can do it anywhere connected to
cs.umb.edu by the Internet, with a running tunnel if off-campus.
Similarly load and show mysql, after looking database/README to see the
exact commands. Report success or any problems.
c. After loading the database, try runOnH2 SystemTest
in
the base directory to see it run the pizza1 system test on H2.
Similarly, using the ORACLE_ environment variables you set up, and the
tunnel, try runOnOracle SystemTest
. Also try runOnMysql
SystemTest.
Report success or any problems.
4. Java Packages. Review or learn about Java packages. There is
a
Java tutorial on packages. Your directory listing of the pizza
project in problem 2 showed many subdirectories of src and bin. These
are all related to the Java packages in use.
a. Find and quote the package directive in PizzaOrderDAO.java that
places its code in its package. What is its directory under src? Under
target/classes (for PizzaOrderDAO.class)?
b. For StudentService.java, what is the package for this code?
What methods of PizzaOrderDAO are called from here? Find and quote the
import statement that allows this StudentService code to access
PizzaOrderDAO methods without long names.
c. Try removing the import statement you found in b. and trying to
compile the project (maven clean package). Report the resulting error.
d. What longer name could be used by StudentService to access the
PizzaOrderDAO type without the import? Show the line of code that
changes.
5. Maven. Read the Maven in 5 Minutes tutorial we partially covered in Class04.pdf (6pp). This one is really too simple because the only dependency is junit.jar, used only for testing. Read the Mkyong.com tutorial. for an example with a dependency for production (non-test) code. We are using a slightly different plugin in pizza1 but the same result of an all-dependencies jar file. If interested, see stackoverflow discussion of these two plugins. Don't worry about the final step of making an "executable jar": we are content to use the all-dependencies jar in the ordinary way, as shown in runOnOracle, etc., and shown in this tutorial before the very end.
Compose a pom.xml for JdbcCheckup to build it to run on Mysql. There
should be one dependency on mysql, which you can copy out of
pizza1/database/pom.xml. Use the standard project structure, generated
by mvn archetype:generate
. using artifactId myjdbc and
your choice of groupid with at least one period in it. Edit the the
resulting pom.xml so that it builds an all-dependencies jar in the
target directory. Show the full archetype:generate command you
used in your homework submission. Create a hw2 directory on pe07 by cd
cs636, then mkdir hw2. Within this directory, run the same
archetype:generate command and copy in your pom.xml. Add files
runOnMysql.sh and runOnMysql.cmd (like those in pizza1). In your
homework submission, show the contents of runOnMysql.sh and output of a
run of JdbcCheckup using one database (your choice) using your setup on
pe07.