|
Chapter 58. JDBC Interface
JDBC is a core API of Java 1.1 and later. It provides a standard set of interfaces to SQL-compliant databases. Postgres provides a type 4 JDBC Driver. Type 4 indicates that the driver is written in Pure Java, and communicates in the database's own network protocol. Because of this, the driver is platform independent. Once compiled, the driver can be used on any platform. Building the JDBC InterfaceCompiling the DriverThe driver's source is located in the src/interfaces/jdbc directory of the source tree. To compile simply change directory to that directory, and type: % make Upon completion, you will find the archive postgresql.jar in the current directory. This is the JDBC driver.
Installing the DriverTo use the driver, the jar archive postgresql.jar needs to be included in the CLASSPATH. ExampleI have an application that uses the JDBC driver to access a large database containing astronomical objects. I have the application and the jdbc driver installed in the /usr/local/lib directory, and the java jdk installed in /usr/local/jdk1.1.6. To run the application, I would use: export CLASSPATH = /usr/local/lib/finder.jar:/usr/local/lib/postgresql.jar:. java uk.org.retep.finder.Main Loading the driver is covered later on in this chapter. |
|||||||||||||||||
With any suggestions or questions please feel free to contact us |