CompSci 316 (Fall 2012):
Introduction to Database Systems

Course Information
Lecture Notes
Assignments
Tentative Syllabus
Programming Notes
Getting Started with the dbcourse Virtual Machine
Getting Started with Gradiance
PostgreSQL Notes
Using ra
JDBC Notes
Tomcat Notes
Django Notes
PHP Notes
XML Notes
Homework/Project Submission
Sakai (Grades/Project Discussion)

Using JDBC with PostgreSQL


A very simple JDBC application for PostgreSQL can be found in the directory /home/dbcourse/examples/jdbc/ on the server. Please see the file README.txt for instructions. If you want to experiment with the code, you should make a copy in your home directory ("cp -r /home/dbcourse/examples/jdbc/ ~/").

Another JDBC application example would be ra (link). Its code is not documented well, but it contains some more advanced examples such as obtaining database metadata, and uses more secure ways of specifying connection properties. The code resides in the directory /home/dbcourse/software/ra-2.1b/.

The example applications here illustrate how to make direct JDBC connections to a database. The JDBC driver and the connection URL might be database-specific, and the application must provide user name and password for remote connections. Hence, this connection method is not ideal in situations where you want to make your application independent from the particular database you are connecting to. A solution is to use a JNDI data source, which hides all database- and connection-specific details. An example of using data sources can be found in our notes on the Tomcat web application server (link).

Here is quick link to the JDBC API documentation online.

For information specific to the PostgreSQL JDBC driver, visit this link. General help on PostgreSQL can be found in our course's PostgreSQL notes (link).

Last updated Wed Sep 12 21:57:59 EDT 2012