Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id C31D59FA387 for ; Mon, 27 Nov 2006 06:18:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 51173-08 for ; Mon, 27 Nov 2006 06:18:22 -0400 (AST) X-Greylist: delayed 00:12:14.825953 by SQLgrey-1.7.4 Received: from mail.gtech.kiev.ua (mail.gtech.kiev.ua [213.186.209.2]) by postgresql.org (Postfix) with ESMTP id 3320B9FA274 for ; Mon, 27 Nov 2006 06:18:24 -0400 (AST) Received: from localhost ([127.0.0.1]) by mail.gtech.kiev.ua (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for pgsql-jdbc@postgresql.org; Mon, 27 Nov 2006 13:06:09 +0200 Message-ID: <456AB85F.4000004@gtech-ua.com> Date: Mon, 27 Nov 2006 12:05:19 +0200 From: Vit Timchishin User-Agent: Thunderbird 1.5.0.8 (X11/20060911) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Exception Error - Please help I've tried everything! References: <9bc001470611252348l5fd9f93fx2c1a0d45b2c082bb@mail.gmail.com> <883e44790611260746h5b75162eue52207ee6505e2a7@mail.gmail.com> <9bc001470611261521m6c8d2f6nec6cb8b6726385d8@mail.gmail.com> <9bc001470611270043p36c00a1eu89754a46e26c58f3@mail.gmail.com> In-Reply-To: <9bc001470611270043p36c00a1eu89754a46e26c58f3@mail.gmail.com> Content-Type: text/plain; charset=KOI8-U Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50 X-Spam-Level: X-Archive-Number: 200611/130 X-Sequence-Number: 16172 Here are few guides: 1) Do not pass file name to "java". Pass fully qualified class name. Your call should be "java -cp postgresql.jar:. PostgresqlClient" 2) You can use "-verbose" to check what jar files or classes are loaded. 3) For netbeans ensure you have jar in "Project properties" -> "Libraries" Greg Peters wrote: > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > This is PostgressqlClient.java as it currently stands: > > > import java.sql.*; > > public class PostgresqlClient{ > public static void main(String[] Arguments) > throws ClassNotFoundException, SQLException{ > > String driver = "org.postgresql.Driver"; > String url ="jdbc:postgresql:CSG"; > String user = "root"; > String pwd = "password"; > > Class.forName(driver); > > Connection con = DriverManager.getConnection(url, user, pwd); > System.err.println("Connection complete"); > > con.close(); > } > } > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > This is some of the commands I have tried and their results: > > > > C:\Documents and Settings\java\GregScratch\src>java -cp > postgresql.jar:. PostgresqlClient.class > Exception in thread "main" java.lang.NoClassDefFoundError: > PostgresqlClient/class > > C:\Documents and Settings\java\GregScratch\src>java -cp > postgresql.jar:. PostgresqlClient.class > Exception in thread "main" java.lang.NoClassDefFoundError: > PostgresqlClient/class > > C:\Documents and Settings\java\GregScratch\src>java -cp > postgresql.jar. PostgresqlClient.class > Exception in thread "main" java.lang.NoClassDefFoundError: > PostgresqlClient/class > > C:\Documents and Settings\java\GregScratch\src>java -cp postgresql.jar > PostgresqlClient.class > Exception in thread "main" java.lang.NoClassDefFoundError: > PostgresqlClient/class > > C:\Documents and Settings\java\GregScratch\src>java -cp postgresql.jar > PostgresqlClient > Exception in thread "main" java.lang.NoClassDefFoundError: > PostgresqlClient > > C:\Documents and Settings\java\GregScratch\src>java -cp > postgresql.jar:. PostgresqlClient > Exception in thread "main" java.lang.NoClassDefFoundError: > PostgresqlClient > > C:\Documents and Settings\java\GregScratch\src> > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > This is what NB says (and I think I have added the module correctly): > > 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) > > Any ideas???? > > I have tried several versions of the postgresql module from the > website too. > > Cheers, > > Greg. > > > > > > > >