Re: Exception Error - Please help I've tried everything!

From: Vit Timchishin <tivv(at)gtech-ua(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Exception Error - Please help I've tried everything!
Date: 2006-11-27 10:05:19
Message-ID: 456AB85F.4000004@gtech-ua.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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.
>
>
>
>
>
>
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Sebastian Esch 2006-11-27 10:39:18 Re: Exception Error - Please help I've tried everything!
Previous Message Greg Peters 2006-11-27 08:43:24 Re: Exception Error - Please help I've tried everything!