Setting Up Your Account for PostgreSQL and Tomcat


We will assume that you are using the C-shell. If you are using another shell, then this may have to be appropriately modified.

Add to your .cshrc file the following:

# add path to use 'psql' to access postgresql database directly
setenv PATH ${PATH}:/local/apps/postgresql/bin

# setup your java environment for compiling servlet
setenv CLASSPATH $PATH
setenv CLASSPATH ${CLASSPATH}:/local/apps/WWW/jakarta-tomcat-5.0.18/common/lib/servlet-api.jar

It is possible that this will soon change.

Direct Access to the PostgreSQL database with 'psql'


Easy access to a database is obtained by using the 'psql' utility. You need not be on an X-windows display (but see warning below), so this is something that can be done while dialing in from home.

To invoke it, simply type psql -U username stores7. 'username' is you account name in PostgreSQL database. 'stores7' is the sample database.

SQL can be run under the Query-language command. A primitive editor is invoked. Commands can also be written in a file and then read in by 'psql'. SQL commands must end with semi-colons.

When you create your own databases, be sure to include your login name (or some obvious modification) in the database name. We will drop any databases we find which do not seem connected to the class. Also, you will be asked which dataspace your database should belong to. (For Informix, a dataspace is a collection of disk locations for table storage.) Do not create your database in the rootdbs dataspace. Put yours in the cis451dbs. Non-system oriented databases in rootdbs may be dropped.

This is a help link on 'psql'.



Documentation Web Links

The documentation is available on the web. Several useful online books could be found at:
http://www.commandprompt.com/ppbook/
http://www.postgresql.org/docs/aw_pgsql_book/index.html
http://www.intermedia.net/support/sql/sqltut.shtm



Setup Tomcat Server for your web application


Here, we just demonstrate one manual way to deploy your web/servlet application on Tomcat. There may be other better methods. Please see the Tomcat documentations for detailed information, especially the deployment.

Suppose:
-- Your account name on ix is "bob".
-- Your local tomcat is at "/nfs/home/users/bob/tomcat-5.0.18/".
-- Your tomcat port is "9001".

Deploy steps:
1) Put your html file "trytom.html" at "/nfs/home/users/bob/tomcat-5.0.18/webapps/servlets-examples". Note: you can open/access your html web page by this URL - "http://ix.cs.uoregon.edu:9001/servlets-examples/trytom.html".
2) Put your compiled servlet class file "QueryState.class" at "/nfs/home/users/bob/tomcat-5.0.18/webapps/servlets-examples/WEB-INF/classes".
3) Modify the "web.xml" file of your local tomcat at "/nfs/home/users/bob/tomcat-5.0.18/webapps/servlets-examples/WEB-INF".
-- Add these two sections to similar places.

    <servlet>
        <servlet-name>QueryState</servlet-name>
        <servlet-class>QueryState</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>QueryState</servlet-name>
        <url-pattern>/servlet/QueryState</url-pattern>
    </servlet-mapping>

4) If the postgres jdbc driver is not at the common lib directory of Tomcat, you need to download and copy the driver to your local tomcat lib directory.
-- The common tomcat lib directory is at "/local/apps/WWW/jakarta-tomcat-5.0.18/shared/lib/" .
-- Your local tomcat lib directory is at "/nfs/home/users/zwu/tomcat-5.0.18/webapps/servlets-examples/WEB-INF/lib/" . If it does not exist, you can create it.
-- The postgres jdbc driver download link: http://jdbc.postgresql.org/download/pg74.1jdbc3.jar