Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 36D98632452 for ; Mon, 13 Apr 2009 12:34:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40869-02 for ; Mon, 13 Apr 2009 12:34:48 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.27]) by mail.postgresql.org (Postfix) with ESMTP id 630706321A9 for ; Mon, 13 Apr 2009 12:34:48 -0300 (ADT) Received: by qw-out-2122.google.com with SMTP id 8so2082393qwh.61 for ; Mon, 13 Apr 2009 08:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=A53k4jaUqaVKj/8sWUZcFMJl1YTvvYlFi8Yv4TJJZ1k=; b=PKuFg6I+UbieGMFhqFxxxNkQsvRspTakNxOu/Kymu4eSeUnbpQAhoD2rNbUghQVIqs RfXegWtrTlYeSTYOJ1N+XRl8WcUmHGj7U9CJQ+gt3EhGw60+boPrubcNwv7mJFxvASxN a2Hci1mb0F/LKiffgY+NLgC6wIUQNz5/JJ4A0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=LtsyBkiy4Sob2DfdSgiKBbA04VmhzIzT7wWY1uPG+jhUe/RLnW0CNILCLt+9uck5QP IZAxGDvnuqTUe56KdYEjkNVTFpW29isWR/fYcDRuvIwYgTORcPa0TVXG60GpCMYnTPhv QRKLgFYaI9+/EyIlPu6M6CjTOZJNNplW565qk= MIME-Version: 1.0 Received: by 10.229.84.82 with SMTP id i18mr1650681qcl.90.1239636887528; Mon, 13 Apr 2009 08:34:47 -0700 (PDT) In-Reply-To: <23013717.post@talk.nabble.com> References: <23013717.post@talk.nabble.com> Date: Mon, 13 Apr 2009 11:34:47 -0400 X-Google-Sender-Auth: 923f04a1ec46e9d1 Message-ID: <491f66a50904130834q10179085x7d712f0b8319dc5a@mail.gmail.com> Subject: Re: Can't get JDBC to compile. Please help. From: Dave Cramer To: IronSheikh Cc: pgsql-jdbc@postgresql.org Content-Type: multipart/alternative; boundary=00163646d53e54e62f0467717442 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200904/44 X-Sequence-Number: 19491 --00163646d53e54e62f0467717442 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit You have to add the actual postgresql jar file to the classpath. Dave On Sun, Apr 12, 2009 at 2:48 PM, IronSheikh wrote: > > I'm a beginner. I installed PostGRESQL 8.3 with edb_pgjdbc.exe on Windows > XP > SP2. > > The following test code won't compile: > package javaapplication1; > import java.sql.*; > > public class Main { > > public static void main(String[] args) { > try > { > helloPostgresql(); > } > catch (Exception ex) > { > System.out.println("***Exception:\n"+ex); > ex.printStackTrace(); > } > } > > public static void helloPostgresql() > throws ClassNotFoundException, SQLException > { > Class.forName("org.postgresql.Driver"); > Connection db = DriverManager.getConnection("jdbc:postgresql:pathos", > "postgres", "cuy4867z"); > > PreparedStatement st = db.prepareStatement("INSERT INTO test VALUES > (?,?,?)"); > st.setInt(1, 5); > st.setString(2, "'$10.00'"); > st.setString(3, "'full checkup'"); > st.executeUpdate(); > st.close(); > > db.close(); > } > > } > > NetBeans says: > ***Exception: > java.lang.ClassNotFoundException: org.postgresql.Driver > java.lang.ClassNotFoundException: org.postgresql.Driver > at java.net.URLClassLoader$1.run(URLClassLoader.java:200) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:188) > at java.lang.ClassLoader.loadClass(ClassLoader.java:307) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) > at java.lang.ClassLoader.loadClass(ClassLoader.java:252) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:169) > at javaapplication1.Main.helloPostgresql(Main.java:36) > at javaapplication1.Main.main(Main.java:24) > BUILD SUCCESSFUL (total time: 0 seconds) > > I've tried adding "E:\Program Files\PostgreSQL\pgJDBC" to the CLASSPATH. > Any > suggestions? > -- > View this message in context: > http://www.nabble.com/Can%27t-get-JDBC-to-compile.-Please-help.-tp23013717p23013717.html > Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com. > > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc > --00163646d53e54e62f0467717442 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable You have to add the actual postgresql jar file to the classpath.

Dav= e

On Sun, Apr 12, 2009 at 2:48 PM, IronSh= eikh <kazisi= ddiqui@gmail.com> wrote:

I'm a beginner. I installed PostGRESQL 8.3 with edb_pgjdbc.exe on Windo= ws XP
SP2.

The following test code won't compile:
package javaapplication1;
import java.sql.*;

public class Main {

=A0 =A0public static void main(String[] args) {
=A0 =A0 try
=A0 =A0 {
=A0 =A0 =A0 helloPostgresql();
=A0 =A0 }
=A0 =A0 catch (Exception ex)
=A0 =A0 {
=A0 =A0 =A0 System.out.println("***Exception:\n"+ex);
=A0 =A0 =A0 ex.printStackTrace();
=A0 =A0 }
=A0 =A0}

=A0 =A0public static void helloPostgresql()
=A0 =A0 =A0 =A0 =A0 =A0throws ClassNotFoundException, SQLException
=A0 =A0{
=A0 =A0 Class.forName("org.postgresql.Driver");
=A0 =A0 Connection db =3D DriverManager.getConnection("jdbc:postgresq= l:pathos",
"postgres", "cuy4867z");

=A0 =A0 PreparedStatement st =3D db.prepareStatement("INSERT INTO tes= t VALUES
(?,?,?)");
=A0 =A0 st.setInt(1, 5);
=A0 =A0 st.setString(2, "'$10.00'");
=A0 =A0 st.setString(3, "'full checkup'");
=A0 =A0 st.executeUpdate();
=A0 =A0 st.close();

=A0 =A0 db.close();
=A0 =A0}

}

NetBeans says:
***Exception:
java.lang.ClassNotFoundException: org.postgresql.Driver
java.lang.ClassNotFoundException: org.postgresql.Driver
=A0 =A0 =A0 =A0at java.net.URLClassLoader$1.run(URLClassLoader.java:200) =A0 =A0 =A0 =A0at java.security.AccessController.doPrivileged(Native Metho= d)
=A0 =A0 =A0 =A0at java.net.URLClassLoader.findClass(URLClassLoader.java:18= 8)
=A0 =A0 =A0 =A0at java.lang.ClassLoader.loadClass(ClassLoader.java:307) =A0 =A0 =A0 =A0at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java= :301)
=A0 =A0 =A0 =A0at java.lang.ClassLoader.loadClass(ClassLoader.java:252) =A0 =A0 =A0 =A0at java.lang.ClassLoader.loadClassInternal(ClassLoader.java= :320)
=A0 =A0 =A0 =A0at java.lang.Class.forName0(Native Method)
=A0 =A0 =A0 =A0at java.lang.Class.forName(Class.java:169)
=A0 =A0 =A0 =A0at javaapplication1.Main.helloPostgresql(Main.java:36)
=A0 =A0 =A0 =A0at javaapplication1.Main.main(Main.java:24)
BUILD SUCCESSFUL (total time: 0 seconds)

I've tried adding "E:\Program Files\PostgreSQL\pgJDBC" to the= CLASSPATH. Any
suggestions?
--
View this message in context: h= ttp://www.nabble.com/Can%27t-get-JDBC-to-compile.-Please-help.-tp23013717p2= 3013717.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

--00163646d53e54e62f0467717442--