HP3000-L Archives

January 2001, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Gavin Scott <[log in to unmask]>
Reply To:
Gavin Scott <[log in to unmask]>
Date:
Wed, 17 Jan 2001 23:36:54 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (104 lines)
Joe writes:

> I compiled my VerySimpleJdbc.java program that is a copy of Cordlandt
> Wilsons example.
>
> I'm getting a PointerException.

Actually you're getting a "NullPointerException", the "UAE" and "GPF" of the
Java world (practically any failing operation will return a reference to
Null, and not noticing the error before trying to use the reference results
in the NullPointerException.  A good candidate for World's Most Generic
Error Condition.

> Does any on have an idea whats going on!

Don't know much about JDBC internals, but rearranging your trace a bit:

> java.lang.NullPointerException
> at java.io.Writer.<init>(Writer.java:75)
> at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:98)
> at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:87)
> at java.io.PrintWriter.<init>(PrintWriter.java:110)
> at java.io.PrintWriter.<init>(PrintWriter.java:94)
> at com.hp.jdbc.allbase.JdbcDriver.<clinit>(JdbcDriver.java:77)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:124)
> at VerySimpleJdbc.main(VerySimpleJdbc.java:15)

Reading up the trace from the bottom, the failure likely is occuring on the
explicit call to Class.forName(<your JDBC driver class name>) that you
typically see at the start of any JDBC program.  By asking for a reference
to the Class object for the driver's class, you cause the system to load
that class, and the initialization (construction) of the Class object allows
the class to register itself with the rest of the JDBC code (which also gets
loaded as a side effect).

It looks like you found com.hp.jdbc.allbase.JdbcDriver ok, and it tried to
create a PrintWriter object which created an OutputStreamWriter object which
created a Writer object which probably was the first thing to actually
*look* at the parameters meing passed to the constructor, and one of them
turned out to be Null.  So perhaps the JDBC driver object failed to open
some connection or file and didn't check the status before trying to wrap
that stream in a PrintWriter object (bad driver <thwack!>).

The trace leading up to the ultimate NullPointerException is mostly standard
Java initialization and all the standard classes that end up getting loaded
as a result of even the simplest reference to any sort of object.  The
interesting stuff starts when your main class gets loaded:

> [Loaded VerySimpleJdbc]
> Start VerySimpleJdbc
> [Loaded java.lang.Package from /usr/local/java/jdk1.2.2/jre/lib/rt.jar]
> [Loaded com.hp.jdbc.allbase.JdbcDriver]
> [Loaded com.hp.jdbc.allbase.Jdbc]
> [Loaded java.sql.Driver from /usr/local/java/jdk1.2.2/jre/lib/rt.jar]

The next three Exception classes that get loaded may be normal operation or
they may be getting loaded in response to actually being trown by the
internals of the JDBC SQL stuff, which again may or may not indicate the
first problem.

> [Loaded java.sql.SQLException from
> /usr/local/java/jdk1.2.2/jre/lib/rt.jar]
> [Loaded java.lang.NumberFormatException from
> /usr/local/java/jdk1.2.2/jre/lib/rt
> .jar]
> [[Loaded java.lang.IllegalArgumentException from
> /usr/local/java/jdk1.2.2/jre/lib
> /rt.jar]

Here we're loading the "Connection" class, and the next class that gets
loaded is PrintWriter which we see in our stack trace, so perhaps the JDBC
driver tried to create a Connection object, this failed, it didn't check,
and then tried to use an output stream associated with the Connection to
create a PrintWriter.  Since the output stream field was Null, eventually
someone notices and bang you get your NullPointerException which isn't
really helpful in indicating what went wrong.

> [Loaded java.sql.Connection from
> /usr/local/java/jdk1.2.2/jre/lib/rt.jar]
> [Loaded java.io.PrintWriter from
> /usr/local/java/jdk1.2.2/jre/lib/rt.jar]
> [Loaded java.sql.DriverManager from
> /usr/local/java/jdk1.2.2/jre/lib/rt.jar]
> [Loaded java.lang.NullPointerException from
> /usr/local/java/jdk1.2.2/jre/lib/rt.
> jar]
> [Loaded java.lang.ExceptionInInitializerError from
> /usr/local/java/jdk1.2.2/jre/
> lib/rt.jar]
> Exception in thread "main" java.lang.ExceptionInInitializerError:
> java.lang.NullPointerException

All of this is mostly in the wild-ass-guess category though.

Not sure what to look at as far as a solution.  Obviously check eveything
that would be different on your system versus the author's system such as
the URL you're going to connect to, the installation of the JDBC stuff, and
I assume that your 3000 has TCP/IP networking configured and running and
that you've started the LOOP NI (:NETCONTROL START;NET=LOOP) and that the
JDBC listener is ready to receive connections.

G.

ATOM RSS1 RSS2