Another java connect problem

From: "Espen Isaksen" <espen(dot)isaksen(at)statkart(dot)no>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Another java connect problem
Date: 2005-04-04 11:15:07
Message-ID: 425121BB.8020603@statkart.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi!

I have studied all the different questions where people have trouble
connecting to PostgreSQL through Java, but it doesn't help me
much. This is a program I first compiled on a Mac and I have no
problems at all there. Now I am on Fedora Linux.

First my code:
Connection dbcon;
java.sql.Connection conn;
String url = "jdbc:postgresql://localhost:5432/espen";

try {
Class.forName("org.postgresql.Driver").newInstance();
}
catch( ClassNotFoundException cnfex ) {
System.out.println("Class not found!");
} //end catch

conn = DriverManager.getConnection(url, "user", "password);
Statement stmt = conn.createStatement();
s = conn.createStatement();

I compile by using this command:
javac @files -classpath postgis.jar:postgresql.jar (where files include
a list of all the .java files)

No problems compiling.

I try to run by:
java road_generalization -verbose -classpath postgis.jar:postgresql.jar

Then I get the usual error message:

Unable to connect
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DataUthenter.connectPostgres(DataUthenter.java:67)
at DataUthenter.<init>(DataUthenter.java:31)
at road_generalization.<init>(road_generalization.java:99)
at road_generalization.main(road_generalization.java:383)

I have tried to change the code in a lot of different ways, but it does not
seem to help much. Can anybody give me some insight in why this
doesn't work. Is my "run command" not correct?

Espen Isaksen
http://www.espenisaksen.com

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nico 2005-04-04 11:56:43 Re: Another java connect problem
Previous Message alvin.yk 2005-04-04 10:32:04 8.0.1 performance question.