In this lab, you will extend your work from the previous lab into the three-tier architecture. All the instructions below assume you are working on one of the MCS department PCs running Linux. I will also assume that you run the applet either through version 1.2.1 of Mozilla, or through appletviewer.
You will first set up a dummy server, which will not access the underlying database that the final, but instead gives a fixed answer regardless of your query. After deploying this dummy version, you will then write an real server which will accurately respond to your queries. In addition to allowing you to query your database, this will also provide you the ability to easily see more information about the movies, courtesy of The Internet Movie Database.
Following is a link to an applet connected to an (occasionally) running dummy server: dummyFindActor.html, which you can check out to see what the dummy server should do.
Following are the files I am providing for you:
source_dir in what follows. So go to wherever you
want to copy these files and type:
cp -r ~karl/public/mcs270/lab4 .
Note that the trailing . is necessary. Go to this
directory and see what is there, including in the subdirectories.
java and html files
in source_dir (as well as its sub-directories), replacing
jstudent with your username.
Warning: All of the commands below should have every
instance of jstudent replaced by you username.
source_dir and compile the three interface
files:
javac -d ~/public_html/codebase *.java
policy from source_dir to
public_html:
cp policy ~/public_html
setenv KARL ~karl
setenv CLASSPATH $KARL/public/mcs270/psql-movies/postgresql.jar:.
setenv CLASSPATH $HOME/public_html/codebase:$CLASSPATH
(Note: you don't actually need postgresql.jar
for the dummy server, but I am including it here since you will need
it later.)
cd clients
javac -d ~/public_html/codebase FindActor.java
cd ..
cd dummy
javac -d ~/public_html/codebase *.java
cd ..
rmic -d ~/public_html/codebase edu.gac.jstudent.movies.dummy.StoreImpl
rmic -d ~/public_html/codebase edu.gac.jstudent.movies.dummy.ChainImpl
ssh kilpinen
Warning: you should again insure that the version of java is
1.4.0; see step 1 of Two-tier Example
(courtesy JavaSoft(TM)) , in order to see how this is done.
setenv KARL ~karl
setenv CLASSPATH $KARL/public/mcs270/psql-movies/postgresql.jar:.
setenv CLASSPATH $HOME/public_html/codebase:$CLASSPATH
java -Djava.rmi.server.codebase=http://kilpinen.mcs.gac.edu/~jstudent/codebase/ \
-Djava.security.policy=$HOME/public_html/policy \
edu.gac.jstudent.movies.dummy.ChainImpl
dummyFindActor.html to
somewhere in your www-docs/ directory, and accessing it
through Mozilla.
Now it is time to make a real server that connects using JDBC
to your database (yielding three tiers), building on the work you did
in the previous lab on SQL and JDBC. One issue you'll run into is that
in this lab, we're looking for movies given an actor's full name
(e.g., "Claude Rains") rather than seperate first and last names
(e.g., "Claude" and "Rains"). To deal with this, you can use SQL's
string concatenation operator, ||. For example, to just
find Claude Rains in the persons table, you could do
select * from persons where fnames || ' ' || lname = 'Claude Rains';
Of course, you want to do a more complex query that also takes the
other tables into account. Make copies of ChainImpl.java and
StoreImpl.java in a different directory. Change the package lines to
a different package as well. Change the name ChainImpl rebinds under
from jstudent-dummy-chain to jstudent-chain. Now edit in the JDBC
code, compile, deploy, and test as above. As with everything, ask if
you need help.
Lab4, now type:
~karl/bin/mcs270/submit Lab4
Instructor: Karl Knight