Skip site navigation (1) Skip section navigation (2)

Re: Can't connect to posgresql through the jdbc driver

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: PG-JDBC Mailing List <pgsql-jdbc(at)postgresql(dot)org>
Cc: Lior K <liork20002000(at)yahoo(dot)com>
Subject: Re: Can't connect to posgresql through the jdbc driver
Date: 2010-03-03 03:20:15
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
[ Replying to list, since poster replied directly to me. I've trimmed
the reply and fixed the broken quoting; please quote correctly in future
replies and reply to the list, not directly to me].

Lior K wrote:
>> Craig Ringer wrote:
>> What's the exact value of CLASSPATH as you set it?
> from within .bashrc  :
> export CLASSPATH
>> Did you set it to the directory containing the .jar ? Or to the .jar its
>> self? You need to put the actual .jar on the CLASSPATH.
> I set it to the jar file as written above

No, you didn't. You set it to the folder CONTAINING the jar. Try:


> I am using netbeans 6.8 ... The project I chose was a java application . The application is supposed to connect to a database which parameters (DB name , userName,Password ) I pass through netbeans config file option (under the "run" section in the menu. I also tried to run it manually with this line:

Eh? If you're using NetBeans, why are you messing with the CLASSPATH
environment variable? Just define libraries and add them to your
netbeans project. See the netbeans introductory tutorial, the built-in
help, the "Libraries" folder in the project, and the "Libraries" entry
in the Tools menu.

For example, I created a library "PostgreSQL JDBC Driver", and added the
postgresql-8.4-701.jdbc.jar to it. If I wanted to use that in an Ant
project (the default netbeans project type) I'd just right-click on the
library list and add "PostgreSQL JDBC Driver" to the list. Now netbeans
will add it to the classpath automatically, copy it into the dist folder
when I do a project build, bundle it up in my application jar when I do
a jar build, and otherwise just take care of it for me.

If you add the sources and javadoc to the library too, you get
source-level debuggging, JavaDoc autocomplete, etc for the library too.

Right now, you're doing things the hard way! You'll get a lot further by
reading the documentation in Netbeans and the basic documentation on the
JVM, "java" command, etc.

( Alternately, if you use Maven, and add a dependency for:

Artifact: postgresql
Group: postgresql
Version: 8.4-701.jdbc4

and it all automagically just happens ).

Craig Ringer

In response to


pgsql-jdbc by date

Next:From: Thomas KellererDate: 2010-03-03 07:11:39
Subject: Re: Can't connect to posgresql through the jdbc driver
Previous:From: Craig RingerDate: 2010-03-03 00:55:46
Subject: Re: Can't connect to posgresql through the jdbc driver

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group