Re: I just can't use the org.postgresql.Driver class... Please help! - Mailing list pgsql-jdbc

From Jan de Visser
Subject Re: I just can't use the org.postgresql.Driver class... Please help!
Date
Msg-id 200604051502.48358.jdevisser@digitalfairway.com
Whole thread Raw
In response to I just can't use the org.postgresql.Driver class... Please help!  (Kamal <kalotus@gmail.com>)
List pgsql-jdbc
On Wednesday 05 April 2006 14:53, Kamal wrote:
> Simple log file making me crazy (javac.log):
>
> JasperReportsTest.java:6: unreported exception
> java.lang.ClassNotFoundException; must be caught or declared to be
> thrown
>    Class.forName("org.postgresql.Driver");
>                 ^
> 1 error
>
> Obviously the file postgresql-8.1-405.jdbc3.jar is there...
>
> Why does it say ClassNotFound if the file is there? Can anyone help me?
> Thank you : )

Well, the class is there at *compile time*. What this is telling you is that
at *runtime* Class.forName() will fail with that exception if the class is
not available *at runtime*. You need to catch the exception, like so:

try {
  Class.forName( "org.postgresql.Driver" );
} catch ( ClassNotFoundException cnfe ) {
  System.err.println( "driver not found!" );
}


I would recommend an introductory Java text.

jan


--
--------------------------------------------------------------
Jan de Visser                     jdevisser@digitalfairway.com

                Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------

pgsql-jdbc by date:

Previous
From: Kamal
Date:
Subject: I just can't use the org.postgresql.Driver class... Please help!
Next
From: "markds75"
Date:
Subject: PostgreSQL (XADataSource) as Tomcat Resource