jdbc question

From: mr_hopkins(at)earthlink(dot)net (Micheal H(dot))
To: pgsql-hackers(at)postgresql(dot)org
Subject: jdbc question
Date: 2000-01-18 06:39:28
Message-ID: 38840aea.7517991@news.earthlink.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I got the pgsql jdbc drivers and their names were jdbc6.5-1.1.jar and
jdbc6.5-1.2.jar. OK everything I've read refers to postgresql.jar

I've tried adding the location of the files to the class path as well
as renaming them, one by one to postgresql.jar and adding the file
name to the classpath. Nothing seems to work. Now I'm not a java pro
so perhaps something's wrong with my code or my understanding of what
to do with the .jar file(s). Here's the code.....It compiles but
never gets past "Failed to load postgresql driver". Would greatly
appreacieate any assistance........

import java.sql.*;

public class SelectApp {
public static void main(String args[]) {
String url = "jdbc:postgresql://gina/testdb";

try {
Class.forName("postgresql.Driver");
}
catch(Exception e) {
System.out.println("Failed to load postgresql
driver.");
return;
}
System.out.println("Loaded driver successfully");
try {
Connection con =
DriverManager.getConnection(url, "", "");
Statement select = con.createStatement();
ResultSet result = select.executeQuery("select
* from cities");

System.out.println("Got results:");
while(result.next()) { // process results one
row at a time
int key = result.getInt(1);
String val = result.getString(2);

System.out.println("key = " + key);
System.out.println("val = " + val);
}
select.close();
con.close();
}
catch(Exception e) {
e.printStackTrace();
}
}
}

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2000-01-18 06:58:23 RE: [HACKERS] How to ignore system indexes
Previous Message Bruce Momjian 2000-01-18 05:53:50 Re: [PATCHES] docs done Re: [HACKERS] LIBPQ patches ...