Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 1D91A634086 for ; Tue, 2 Mar 2010 23:20:32 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 17056-01-5 for ; Wed, 3 Mar 2010 03:20:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 07297633CE3 for ; Tue, 2 Mar 2010 23:20:20 -0400 (AST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 3DABF1E044D; Wed, 3 Mar 2010 11:20:18 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id KZkDGs8hpNTW; Wed, 3 Mar 2010 11:20:16 +0800 (WST) Received: from [192.168.3.115] (unknown [192.168.3.115]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 3E42D1E0443; Wed, 3 Mar 2010 11:20:16 +0800 (WST) Message-ID: <4B8DD56F.9040109@postnewspapers.com.au> Date: Wed, 03 Mar 2010 11:20:15 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: PG-JDBC Mailing List CC: Lior K Subject: Re: Can't connect to posgresql through the jdbc driver References: <759461.26544.qm@web35603.mail.mud.yahoo.com> <4B8DB392.2020608@postnewspapers.com.au> <748530.91320.qm@web35603.mail.mud.yahoo.com> In-Reply-To: <748530.91320.qm@web35603.mail.mud.yahoo.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.74 tagged_above=-10 required=5 tests=BAYES_20=-0.74 X-Spam-Level: X-Archive-Number: 201003/5 X-Sequence-Number: 20345 [ 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