help in postgres & jdbc
От | Seema Noor |
---|---|
Тема | help in postgres & jdbc |
Дата | |
Msg-id | 20010321224749.16024.qmail@web3301.mail.yahoo.com обсуждение исходный текст |
Список | 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/
В списке pgsql-interfaces по дате отправления: