Lab09 JDBCWebApp01 PDF
Lab09 JDBCWebApp01 PDF
Prior to Lab
1. Review this laboratory handout prior to lab.
2. Make sure that the Albums database is installed and available in your MySQL
instance on CSE
3. Review the SQL and JDBC lecture notes
4. Review a JDBC tutorial from Oracle:
http://download.oracle.com/javase/tutorial/jdbc/
1
The navigator will be responsible for reading the instructions and telling the driver
what to do next. The driver will be in charge of the keyboard and workstation. Both
driver and navigator are responsible for suggesting fixes and solutions together. Neither
the navigator nor the driver is in charge. Beyond your immediate pairing, you are
encouraged to help and interact and with other pairs in the lab.
Each week you should alternate: if you were a driver last week, be a navigator next,
etc. Resolve any issues (you were both drivers last week) within your pair. Ask the lab
instructor to resolve issues only when you cannot come to a consensus.
Because of the peer programming setup of labs, it is absolutely essential that you com-
plete any pre-lab activities and familiarize yourself with the handouts prior to coming
to lab. Failure to do so will negatively impact your ability to collaborate and work with
others which may mean that you will not be able to complete the lab.
Getting Started
Note: Unless you are familiar with Java Applications Servers and have one installed on
your laptop, you will need to use the lab computers for this lab. In addition, it would
be a good idea to reset your Albums database by rerunning the SQL script from a prior
lab.
For this lab, you will need to use the JEE (Java Enterprise Edition) version of Eclipse,
not the JSE (Java Standard Edition). In Windows, click the start menu and enter
Eclipse, the Java EE Eclipse should show up, select this version. You may use the
same workspace as with the JSE (Java Standard Edition) version of Eclipse.
Alternatively (and recommended) you can use the Eclipse version in the Linux partition,
which will enable you to deploy locally to your lab machine instead of the csce server.
To use this version of Eclipse:
2
1. Restart your lab computer and choose openSUSE. Login with your usual CSE
credentials.
2. Once logged into Linux, go to Applications Search and open up a Termi-
nal
3. Launch eclipse by executing
/usr/local/bin/eclipse &
(the ampersand launches Eclipse in the background so you can still use the terminal
session)
Once youve got Eclipse running, clone the project code for this lab from GitHub using
the URL, https://github.com/cbourke/CSCE156-Lab09-JDBCI. Refer to Lab 01 for
instructions on how to clone a project from GitHub.
Activities
3
A Test class has been provided for you to test your getAlbumSummaries()
method which you can also adapt to test your getDetailedAlbum() method.
You should use it to debug your methods before deploying your application.
You have two options for deploying your application as a Web Archive (WAR) file to an
application server.
If you chose to do this lab in the Linux version, then follow these instructions.
1. Right click your project and select Export. . . , select Web, WAR file, Next
2. Click Browse and select a directory (your home directory is recommended) and file
to export to; name the file loginLab09.war where login is replaced by your
cse login.
3. Return to your terminal and copy the WAR file to glassfishs autodeploy directory:
cp loginLab09.war ~glassfish/glassfish/domains/domain1/autodeploy
4. Open a web browser (Applications Firefox) and go to the following url:
http://localhost:8080/loginLab09 where login is replaced with your CSE lo-
gin.
If you chose to do this lab in the Windows version, then follow these instructions.
1. Export your application in a Web Archive File (WAR): right click your project
and choose Export Export. . . Web WAR file
2. Click Browse and select a directory to export it to, name the file loginLab09.war
where login is replaced by your cse login. The file should now be in the directory
you selected.
3. Copy the WAR file to the root of your CSE directory (copy it to your Z: drive)
4. SSH (PuTTY) into csce.unl.edu (not cse.unl.edu ) using your cse login
5. Copy the war file to the servers glassfish auto deploy directory with the command
cp loginLab09.war ~glassfish/glassfish/domains/domain1/autodeploy/
4
6. Make sure that the file has proper permissions by executing the following from the
command line:
chmod 755 ~glassfish/glassfish/domains/domain1/autodeploy/loginLab09.war
where, login is replaced by your cse login. If necessary, you may need to give
glassfish a kick in the butt by executing:
touch ~glassfish/glassfish/domains/domain1/autodeploy/loginLab09.war
7. Open a web browser and go to the following URL: http://csce.unl.edu:8080/
loginLab09/ where login is replaced by your CSE login. Unless there were
problems with your code, the webapp should now work, you can click on album
titles or bands to be taken to another page that gives further details.
Complete the worksheet and have your lab instructor sign off on it. Before you leave,
make sure you undeploy your web app by deleting the WAR file from the glassfish
autodeploy directory:
rm ~glassfish/glassfish/domains/domain1/autodeploy/loginLab09.war