Thread: j2sdk1.4.2_01 vs. CLASSPATH problem?

j2sdk1.4.2_01 vs. CLASSPATH problem?

From
Yasunari Tosa
Date:
Hi,

I would really appreciate your help in learning JDBC through PostgreSQL.

Under j2sdk1.4.2_01, setting CLASSPATH causes exception in class not
found error.   This exception is thrown even the simplest HelllWorld
class.  Did they(SUN) change the behavior of CLASSPATH?

I'm running RedHat 9 with Linux 2.4.20-19.9 kernel.

Here is the details.

/home/tosa/pgsqlDev/java>javac client2.java
client2.java:7: package org.postgresql.util does not exist
import org.postgresql.util.*;
^
client2.java:67: cannot resolve symbol
symbol  : class PSQLException
location: class client2
    catch(PSQLException e)
          ^
2 errors

......OK.  I set CLASSPATH
/home/tosa/pgsqlDev/java>setenv CLASSPATH /usr/share/pgsql/postgresql.jar
......Now compiles
/home/tosa/pgsqlDev/java>javac client2.java
......However, I cannot run
/home/tosa/pgsqlDev/java>java client2
Exception in thread "main" java.lang.NoClassDefFoundError: client2
......So, I unsetenv CLASSPATH
/home/tosa/pgsqlDev/java>unsetenv CLASSPATH
/home/tosa/pgsqlDev/java>java client2
Exception in thread "main" java.lang.NoClassDefFoundError:
org/postgresql/util/PSQLException


Re: j2sdk1.4.2_01 vs. CLASSPATH problem?

From
"Scot P. Floess"
Date:
Yasunari:

If I read your email correctly you are able to compile but not run...

If so, you need to do this:

export CLASSPATH=/usr/share/pgsql/postgresql.jar:/home/tosa/pgsqlDev/java

Since client2 "lives" in /home/tosa/pgsqlDev/java that needs to be part of the CLASSPATH...

Scot

-----Original Message-----
From: Yasunari Tosa <ytosa@att.net>
Sent: Sep 30, 2003 11:07 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] j2sdk1.4.2_01 vs. CLASSPATH problem?

Hi,

I would really appreciate your help in learning JDBC through PostgreSQL.

Under j2sdk1.4.2_01, setting CLASSPATH causes exception in class not
found error.   This exception is thrown even the simplest HelllWorld
class.  Did they(SUN) change the behavior of CLASSPATH?

I'm running RedHat 9 with Linux 2.4.20-19.9 kernel.

Here is the details.

/home/tosa/pgsqlDev/java>javac client2.java
client2.java:7: package org.postgresql.util does not exist
import org.postgresql.util.*;
^
client2.java:67: cannot resolve symbol
symbol  : class PSQLException
location: class client2
    catch(PSQLException e)
          ^
2 errors

......OK.  I set CLASSPATH
/home/tosa/pgsqlDev/java>setenv CLASSPATH /usr/share/pgsql/postgresql.jar
......Now compiles
/home/tosa/pgsqlDev/java>javac client2.java
......However, I cannot run
/home/tosa/pgsqlDev/java>java client2
Exception in thread "main" java.lang.NoClassDefFoundError: client2
......So, I unsetenv CLASSPATH
/home/tosa/pgsqlDev/java>unsetenv CLASSPATH
/home/tosa/pgsqlDev/java>java client2
Exception in thread "main" java.lang.NoClassDefFoundError:
org/postgresql/util/PSQLException


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Scot P. Floess

(252) 478-8087 (home)
(864) 244-7309 (apartment)
(864) 236-2472 (work)

Chief Architect JPlate       http://sourceforge.net/projects/jplate
Chief Architect JavaPIM    http://sourceforge.net/projects/javapim

Re: j2sdk1.4.2_01 vs. CLASSPATH problem?

From
Andreas Prohaska
Date:
Hi,

if you just want to get started with JDBC let me point out that
you should not work with any classes of the postgres driver
directly. The good thing aboubt JDBC is that your program
only uses the set of interfaces and basic objects defined in the
java.sql.* package and does not care about the underlying driver.

You don't need any "import org.postgresql." statements and
you should not catch "PGException". Catch "SQLException" instead
and load the driver with:

    Class.forName("org.postgresql.Driver");
    Connection con =
DriverManager.getConnection("jdbc:postgresql://host/db");

The Java tutorial (somewhere below http://java.sun.com)
explains this very well.


    Andreas

> -----Ursprüngliche Nachricht-----
> Von: Yasunari Tosa [mailto:ytosa@att.net]
> Gesendet: Mittwoch, 1. Oktober 2003 05:07
> An: pgsql-jdbc@postgresql.org
> Betreff: [JDBC] j2sdk1.4.2_01 vs. CLASSPATH problem?
>
>
> Hi,
>
> I would really appreciate your help in learning JDBC through
> PostgreSQL.
>
> Under j2sdk1.4.2_01, setting CLASSPATH causes exception in class not
> found error.   This exception is thrown even the simplest HelllWorld
> class.  Did they(SUN) change the behavior of CLASSPATH?
>
> I'm running RedHat 9 with Linux 2.4.20-19.9 kernel.
>
> Here is the details.
>
> /home/tosa/pgsqlDev/java>javac client2.java
> client2.java:7: package org.postgresql.util does not exist
> import org.postgresql.util.*;
> ^
> client2.java:67: cannot resolve symbol
> symbol  : class PSQLException
> location: class client2
>     catch(PSQLException e)
>           ^
> 2 errors
>
> ......OK.  I set CLASSPATH
> /home/tosa/pgsqlDev/java>setenv CLASSPATH
> /usr/share/pgsql/postgresql.jar
> ......Now compiles
> /home/tosa/pgsqlDev/java>javac client2.java
> ......However, I cannot run
> /home/tosa/pgsqlDev/java>java client2
> Exception in thread "main" java.lang.NoClassDefFoundError: client2
> ......So, I unsetenv CLASSPATH
> /home/tosa/pgsqlDev/java>unsetenv CLASSPATH
> /home/tosa/pgsqlDev/java>java client2
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/postgresql/util/PSQLException
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 8: explain analyze is your friend
>