Subject | Re: Nullpointer Exception when connecting with Beta2 |
---|---|
Author | Thomas Kellerer |
Post date | 2005-08-21T17:07:16Z |
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
code for years now and all major JDBC drivers (Oracle, Postgres, JTDS,
HSQLDB, McKoi, Firebird 1.x, SQL Anywhere, DB2) worked without
problems. But reading the docs for setContextClassLoader() seems to
indicate that this should not create problems for other drivers.
One question though (this is getting a bit off-topic, I know). As this
is a multi-threaded application, do I need to set that for each and
every Thread I create, or is it sufficient to set this in the thread
that is loading and instantiating the driver?
Cheers and thanks for your help!
Thomas
<rrokytskyy@a...> wrote:
> > That error occurs in 1.5.5, what about the NPE in 2.0?fact
>
> The NPE should be fixed in HEAD, but it will not solve your problem.
>
> Driver uses "services" concept in Java, which in turn relies on the
> that context classloader is set correctly. You have to add to you code:provider
>
>Thread.currectThread().setContextClassLoader(classLoader);
>
> before calling Class.newInstance() method of FBDriver class. The same
> problem you will encounter when trying to access, for example, JAXP
> loaded from URL.Thanks Roman, that solved my problem. Although I have been using this
>
code for years now and all major JDBC drivers (Oracle, Postgres, JTDS,
HSQLDB, McKoi, Firebird 1.x, SQL Anywhere, DB2) worked without
problems. But reading the docs for setContextClassLoader() seems to
indicate that this should not create problems for other drivers.
One question though (this is getting a bit off-topic, I know). As this
is a multi-threaded application, do I need to set that for each and
every Thread I create, or is it sufficient to set this in the thread
that is loading and instantiating the driver?
Cheers and thanks for your help!
Thomas