Re: a little disillusioned - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: a little disillusioned
Date
Msg-id 400E1449.2030608@opencloud.com
Whole thread Raw
In response to a little disillusioned  ("Frequency UnKnown" <captainmofopants@hotmail.com>)
List pgsql-jdbc
Frequency UnKnown wrote:
> well, my ploy failed. having never got a decent answer from any
> technical forum, i had to try.

I'm not sure what you mean here. To get a decent answer it helps to ask
a clear question.

> so back to the tried and tested method:
>
> can anyone explain to me why tomcat 5 will not find
> org.postgresql.Driver when it is definitely there?

Have you tried the Tomcat lists? Does whatever you're doing work with
other JDBC drivers if you change org.postgresql.Driver to their driver
implementation class?

> So what's the difference between me directly instantiating a class
> (which it seems i can do) and calling Class.forName()/createInstance()
> (or whatever it is) in terms of where Java looks for classes? as i said,
> the classpath for my system, for java, and for tomcat are all pointed to
> the place where I have put the JAR.

In theory there should be no difference between 'new foo()' and
'Class.forName("foo").newInstance()' other than in how exceptions are
reported (however note that the class you execute these code fragments
in becomes significant). However you haven't given us enough information
to go on here. At a minimum, what are the exact exceptions & stack
traces you see? Can you provide the code that does work vs. the code
that doesn't?

You mentioned an InstantiationException (or InstantiationError?) in your
previous mail. You should only get this if trying to instantiate an
abstract class or interface. This might happen if you're using a driver
jar that's built for an older JDBC version than the actual version being
used -- as the newer JDBC methods will have no implementation. (or do
you get an IncompatibleClassChangeError or AbstractMethodError in this
case? I forget..). But this shouldn't happen on instantiation of
org.postgresql.Driver itself, since that doesn't actually build any
version-dependent objects until connect() is called.

BTW, you shouldn't have to instantiate org.postgresql.Driver yourself --
just ensure the class is loaded (Class.forName("org.postgresql.Driver"))
and it'll be available via java.sql.DriverManager. Or is this
instantiation happening in the guts of Tomcat?

> i'm running debian, if that helps.

Check that you don't have a different version of the driver sitting
around somewhere elsewhere in the classpath, IIRC debian likes to
install jars into /usr/share/java, perhaps you have an older version there?

-O

pgsql-jdbc by date:

Previous
From: "Frequency UnKnown"
Date:
Subject: a little disillusioned
Next
From: Jonathan Gold
Date:
Subject: Re: a little disillusioned