pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Peters <gregpeters79@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Exception Error - Please help I've tried everything!
Date: Sun, 26 Nov 2006 17:48:36 +1000
Message-ID: <9bc001470611252348l5fd9f93fx2c1a0d45b2c082bb@mail.gmail.com> (raw)

Hello all,

I'm trying to get the following simple program to run just to confirm a
connection to the database:

//PostgresqlClient.java

import java.sql.*;

public class PostgresqlClient{
    public static void main(String[] arguments)
        throws ClassNotFoundException, SQLException{

        String driver = "org.postgresql.Driver";
        String url ="localhost";
        String user = "root";
        String pwd = "password";

        Class.forName(driver);

        Connection con = DriverManager.getConnection(url, user, pwd);
        System.err.println("Connection complete");

        con.close();
    }
}



I keep getting the folowing errors:

Exception in thread "main" 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:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:164)
        at PostgresqlClient.main(PostgresqlClient.java:12)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

I have tried adding the postgresql.jar file to my CLASSPATH, and have also
tried copying the postgresql.jar file to the same directory as the
PostgresqlClient.java and PostgresqlClient.class directories. I have also
tried running the following from the command line:

java -classpath postgresql.jar PostgresqlClient.class

I am using jdk1.5.0_09 and have tried using nearly all the available
postgresql.jar files available.

Any advice would be most appreciated.

Cheers,

Greg Peters....

view thread (11+ messages)  latest in thread

Message-ID: <9bc001470611252348l5fd9f93fx2c1a0d45b2c082bb@mail.gmail.com>
Permalink:  ../9bc001470611252348l5fd9f93fx2c1a0d45b2c082bb@mail.gmail.com/
Also on:    postgresql.org/message-id/9bc001470611252348l5fd9f93fx2c1a0d45b2c082bb@mail.gmail.com

 · 

reply

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: gregpeters79@gmail.com
  Subject: Re: Exception Error - Please help I've tried everything!
  In-Reply-To: <9bc001470611252348l5fd9f93fx2c1a0d45b2c082bb@mail.gmail.com>
  References: <9bc001470611252348l5fd9f93fx2c1a0d45b2c082bb@mail.gmail.com>

* 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