From: Craig Ringer <craig@postnewspapers.com.au>
To: PG-JDBC Mailing List <pgsql-jdbc@postgresql.org>
Cc: Lior K <liork20002000@yahoo.com>
Subject: Re: Can't connect to posgresql through the jdbc driver
Date: Wed, 03 Mar 2010 11:20:15 +0800
Message-ID: <4B8DD56F.9040109@postnewspapers.com.au> (raw)
In-Reply-To: <748530.91320.qm@web35603.mail.mud.yahoo.com>
References: <759461.26544.qm@web35603.mail.mud.yahoo.com>
<4B8DB392.2020608@postnewspapers.com.au>
<748530.91320.qm@web35603.mail.mud.yahoo.com>
[ 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 :
>
> CLASSPATH=$CLASSPATH:/opt/PostgreSQL/pgJDBC/
> 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:
CLASSPATH=$CLASSPATH:/opt/PostgreSQL/pgJDBC/postgresql-8.4-701.jdbc.jar
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: craig@postnewspapers.com.au, liork20002000@yahoo.com
Subject: Re: Can't connect to posgresql through the jdbc driver
In-Reply-To: <4B8DD56F.9040109@postnewspapers.com.au>
References: <759461.26544.qm@web35603.mail.mud.yahoo.com> <4B8DB392.2020608@postnewspapers.com.au> <748530.91320.qm@web35603.mail.mud.yahoo.com> <4B8DD56F.9040109@postnewspapers.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox