Re: org.postgresql.Driver

From: "Announce" <truthhurts(at)insightbb(dot)com>
To: <bernardolg(at)gmail(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: org.postgresql.Driver
Date: 2005-11-18 03:49:44
Message-ID: KBEKKNMFLELKGIADDEPEKEMMCCAA.truthhurts@insightbb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hey Bernardo,

I'm a PG rookie but I DO know Java. Your PATH env variable doesn't need to
include the JDBC .jar but your CLASSPATH definitely does need to include the
appropriate .jar file. You could verify that your environment knows about
he jar file by doing something like:

System.out.println(System.getProperty("java.class.path"));

At the top of the main method.

Sometimes I make a mistake of misspelling a the path to that file or another
one. If you see that jar file in the System.out output, you know that it's
setting up your classpath ok. You can verify spelling by copy/pasting part
of the java.class.path output into the dos prompt and doing something like:

dir "C:\Archivos de
programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc2ee.jar"

It should find the file specified. I can also tell you that on my WinXP Pro
install, I do not need to include the quotation marks (") around the path
names. I'm thinking that this is causing a problem. So

%JAVA_HOME%\jre\lib;"C:\Archivos de
programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc2.jar";"C:\Archivos
de programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc2ee.jar";"C:\Archivos
de programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc3.jar"

would become:

%JAVA_HOME%\jre\lib;C:\Archivos de
programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc2.jar;C:\Archivos
de programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc2ee.jar;C:\Archivos
de programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc3.jar

without the carriage returns.

Give that a try.

-Aaron
-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Bernardo López
Sent: Thursday, November 17, 2005 8:51 PM
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] org.postgresql.Driver

Greetings!
I am starting to learn Java, and starting to use PostGreSQL too.
I need some major help here.
I am working under Windows XP Home Edition, and working with:

PostgreSQL 8.0.
pgAdmin III, v. 1.2.2.
jdk1.5.0_04.
JCreator 3.50 LE.

I am trying to run this example:

// File Connect.java
// Code starts here.
import java.sql.*;
public class Connect {
public static void main(String[] args) {
Connection cnn;
try {
Class.forName("org.postgresql.Driver");
cnn =
DriverManager.getConnection("jdbc:postgresql://localhost:5432/","postgres","
");
Statement stmt = cnn.createStatement();
int login=1;
ResultSet rs = stmt.executeQuery("select * from usuarios");
if (rs!=null) {
while (rs.next()) {
System.out.println(rs.getString("login"));
System.out.println(rs.getString("password"));
System.out.println(rs.getString("nombre"));
}
}
rs.close();
stmt.close();
cnn.close();
} catch (Exception e) {
System.out.println(e);
}

}
}
// Code ends here.

But I keep getting the error message:

java.lang.ClassNotFoundException: org.postgresql.Driver

I've read a couple of related messages in this and other forums, but
nothing yet.
After many attempts, my PATH, CLASSPATH and other environment
variables are set like this:

- - - -
PATH
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%JAVA_HOME%\bi
n
- - - -
JAVA_HOME
C:\Archivos de programa\Java\jdk1.5.0_04
- - - -
CLASSPATH
%JAVA_HOME%\jre\lib;"C:\Archivos de
programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc2.jar";"C:\Archivos
de programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc2ee.jar";"C:\Archivos
de programa\PostgreSQL\8.0\jdbc\postgresql-8.0-311.jdbc3.jar"
- - - -
QTJAVA
"C:\Archivos de programa\Java\jre1.5.0_04\QTJava.zip"
- - - -

All help will be appreciated!

Keep posting!

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 11/16/2005

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 11/16/2005

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Bernardo López 2005-11-18 04:45:32 Re: org.postgresql.Driver
Previous Message Bernardo López 2005-11-18 02:51:13 org.postgresql.Driver