pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql-jdbc and Java
4+ messages / 3 participants
[nested] [flat]

* pgsql-jdbc and Java
@ 2005-08-03 15:39 abdelkader belkadi <contactbelkadi@yahoo.fr>
  2005-08-03 15:55 ` Re: pgsql-jdbc and Java Xavier Poinsard <xpoinsard@free.fr>
  2005-08-04 00:05 ` Re: pgsql-jdbc and Java Oliver Jowett <oliver@opencloud.com>
  0 siblings, 2 replies; 4+ messages in thread

From: abdelkader belkadi @ 2005-08-03 15:39 UTC (permalink / raw)
  To: pgsql-jdbc

Hello,
I developped my java project with Java NetBeans IDE,
the code connects to a postgreSQL database using the postgresql-8.1dev-400.jdbc3.jar driver, the project builds and executes correctly when using the IDE, however when trying to use the DOS command line as follow:
D:\java -jar projectpath/projectname.jar
the following error is generated:
Class not found !
java.lang.ClassNotFoundException: org.postgresql.Driver
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at logfilerewriter.Main.connectDb(Main.java:235)
        at logfilerewriter.Main.main(Main.java:45)
I checked the class path, it is correctly set.
The error disapears if I don't call the method that connects to the database, which means that their is no CLASSPATH problem.
 
does somebody has the solution, or met this problem before...?
 
thank you in advance
 
 

		
---------------------------------
 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici !  

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql-jdbc and Java
  2005-08-03 15:39 pgsql-jdbc and Java abdelkader belkadi <contactbelkadi@yahoo.fr>
@ 2005-08-03 15:55 ` Xavier Poinsard <xpoinsard@free.fr>
  1 sibling, 0 replies; 4+ messages in thread

From: Xavier Poinsard @ 2005-08-03 15:55 UTC (permalink / raw)
  To: abdelkader belkadi <contactbelkadi@yahoo.fr>; +Cc: pgsql-jdbc

abdelkader belkadi a écrit :
> Hello,
> I developped my java project with Java NetBeans IDE,
> the code connects to a postgreSQL database using the 
> postgresql-8.1dev-400.jdbc3.jar driver, the project builds and executes 
> correctly when using the IDE, however when trying to use the DOS command 
> line as follow:
> D:\java -jar projectpath/projectname.jar
> the following error is generated:
> Class not found !
> java.lang.ClassNotFoundException: org.postgresql.Driver
>         at java.net.URLClassLoader$1.run(Unknown Source)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(Unknown Source)
>         at java.lang.ClassLoader.loadClass(Unknown Source)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>         at java.lang.ClassLoader.loadClass(Unknown Source)
>         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Unknown Source)
>         at logfilerewriter.Main.connectDb(Main.java:235)
>         at logfilerewriter.Main.main(Main.java:45)
> I checked the class path, it is correctly set.
> The error disapears if I don't call the method that connects to the 
> database, which means that their is no CLASSPATH problem.

No, it means that there is a class path problem.
Could you triple check your CLASSPATH ?
What if you add " -cp path_to_postgresqldriver.jar " to your command line ?






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql-jdbc and Java
  2005-08-03 15:39 pgsql-jdbc and Java abdelkader belkadi <contactbelkadi@yahoo.fr>
@ 2005-08-04 00:05 ` Oliver Jowett <oliver@opencloud.com>
  2005-08-04 08:12   ` Re: pgsql-jdbc and Java abdelkader belkadi <contactbelkadi@yahoo.fr>
  1 sibling, 1 reply; 4+ messages in thread

From: Oliver Jowett @ 2005-08-04 00:05 UTC (permalink / raw)
  To: abdelkader belkadi <contactbelkadi@yahoo.fr>; +Cc: pgsql-jdbc

abdelkader belkadi wrote:

> D:\java -jar projectpath/projectname.jar
> the following error is generated:
> Class not found !
> java.lang.ClassNotFoundException: org.postgresql.Driver

> The error disapears if I don't call the method that connects to the
> database, which means that their is no CLASSPATH problem.

A ClassNotFoundException means you *do* have a classpath problem,
whether you like it or not. That exception means that the JVM cannot
find the PostgreSQL JDBC driver class, i.e. it's not in the classpath.

Using -jar has the unexpected behaviour that it makes the JVM completely
ignore any CLASSPATH environment setting. So unless projectname.jar
includes the postgresql driver itself, or references it via manifest
Class-Path, this isn't going to work.

Try an explicit classname and classpath (that includes both the driver
jar and projectname.jar) instead of using -jar.

(also, doesn't the win32/dos JVM expect paths in backslash form? you've
got forward slashes above)

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql-jdbc and Java
  2005-08-03 15:39 pgsql-jdbc and Java abdelkader belkadi <contactbelkadi@yahoo.fr>
  2005-08-04 00:05 ` Re: pgsql-jdbc and Java Oliver Jowett <oliver@opencloud.com>
@ 2005-08-04 08:12   ` abdelkader belkadi <contactbelkadi@yahoo.fr>
  0 siblings, 0 replies; 4+ messages in thread

From: abdelkader belkadi @ 2005-08-04 08:12 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc


I stored my driver in the lib directory of the JDK.

but I manually moved the driver packages in the packages tree of my IDE, and it seems to be working correctly.

Thanks.

Oliver Jowett <oliver@opencloud.com> a écrit :
abdelkader belkadi wrote:

> D:\java -jar projectpath/projectname.jar
> the following error is generated:
> Class not found !
> java.lang.ClassNotFoundException: org.postgresql.Driver

> The error disapears if I don't call the method that connects to the
> database, which means that their is no CLASSPATH problem.

A ClassNotFoundException means you *do* have a classpath problem,
whether you like it or not. That exception means that the JVM cannot
find the PostgreSQL JDBC driver class, i.e. it's not in the classpath.

Using -jar has the unexpected behaviour that it makes the JVM completely
ignore any CLASSPATH environment setting. So unless projectname.jar
includes the postgresql driver itself, or references it via manifest
Class-Path, this isn't going to work.

Try an explicit classname and classpath (that includes both the driver
jar and projectname.jar) instead of using -jar.

(also, doesn't the win32/dos JVM expect paths in backslash form? you've
got forward slashes above)

-O


		
---------------------------------
 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici !  

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2005-08-04 08:12 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-03 15:39 pgsql-jdbc and Java abdelkader belkadi <contactbelkadi@yahoo.fr>
2005-08-03 15:55 ` Xavier Poinsard <xpoinsard@free.fr>
2005-08-04 00:05 ` Oliver Jowett <oliver@opencloud.com>
2005-08-04 08:12   ` abdelkader belkadi <contactbelkadi@yahoo.fr>

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