help in postgres & jdbc

From: Seema Noor <seema_56(at)yahoo(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: help in postgres & jdbc
Date: 2001-03-21 22:47:49
Message-ID: 20010321224749.16024.qmail@web3301.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces


i want to know how to start jdbc for postgreql in red
hat linux 7.0. i'm using jdk1.2.2
i have installed red hat linux 7.0 full and there are
four jdbc.......jar files of different version. i
found two methods to do so:

1) i have set the path CLASSPATH=$CLASSPAH
/usr/lib/pgsql/jdbc6.5.1.2.jar
(don't the exact version but it started with 6)
but when ran the file there was exception of
CLASSNOTFOUND. when this exception was caugth it gave
the error message "postgresql/driver"
how do i set the driver? my simplest program is

import java.sql.*;

class PostgreSQLTest {
public static void main (String[] args) {
try {
Driver driver = (Driver)

Class.forName("postgresql.Driver").newInstance();
DriverManager.registerDriver(driver);

String url = "jdbc:postgresql:javatest";
Connection con =
DriverManager.getConnection(url, "postgres", "");
Statement stm = con.createStatement();

stm.setQueryTimeout(10);
ResultSet rs = stm.executeQuery("select col1
from test");

rs.next();

System.out.println(rs.getString(1));

} catch (SQLException e) {

System.out.println("Exception!");
System.out.println(e.toString());
}
}


where the database name is "javatest" and the table
name is "test".
in the statement :
Connection con = DriverManager.getConnection(url,
"postgres", "");
i even have put "root" instead of "postgres" and put
the root password (just to try) but it didn't work
this way either.

2) i found somewhere to compile the driver from
src/interface/jdbc dir (in the postgresql folder) to
get postgresql.jar and then set the class path for
this postgresql.jar
this src/interface/jdbc is not in my system under
postgresql directory when i installed the linux
completely. but i found these directories in
postgresql-7.0.2.tar.

i think that the first method is correct. could u
please help me to get started? is there something i am
missing in the first method?

please reply me soon,
regards,
Seema

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter T Mount 2001-03-22 14:18:58 Re: problem compiling the jdbc driver
Previous Message Peter Eisentraut 2001-03-21 22:06:10 Re: problem compiling the jdbc driver