CompSci 316 (Fall 2013):
Introduction to Database Systems

Course Information   Lecture Notes   Assignments   Tentative Syllabus   Programming Notes   Homework/Project Submission   Sakai (Grades & Solutions)   Piazza (Q&A)
Getting Started with Windows Azure (Linux) Virtual Machine   Getting Started with Gradiance   PostgreSQL Notes   Using ra   JDBC Notes   Tomcat Notes   Django Notes   PHP Notes   XML Notes

Using JDBC with PostgreSQL


A very simple JDBC application for PostgreSQL can be found in the directory /opt/dbcourse/examples/jdbc/. 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 /opt/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 specifies connection properties using a properties file. The code resides in the directory /opt/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 11 10:18:08 EDT 2013