From: | Peter Royal <proyal(at)pace2020(dot)com> |
---|---|
To: | "Scot P(dot) Floess" <floess(at)mindspring(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: NPE in creating a SQLException |
Date: | 2003-07-29 16:16:27 |
Message-ID: | 01D0EBEF-C1E0-11D7-AC9E-000393B61B56@pace2020.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On Tuesday, July 29, 2003, at 11:50 AM, Scot P. Floess wrote:
> Does your class have a toString() method? You mention that this is
> occurring in a constructor. Certainly if your toString() has object
> members being printed in such a way as method calls are performed on
> those object prior to their being set to instances there could be
> issue (ie NullPointerException). However, assuming this to be true,
> one would hope the stack trace would indicate the toString() method.
That's the rub, its not in my class :)
>> java.lang.NullPointerException
>> at java.io.PrintWriter.write(PrintWriter.java:247)
>> at java.io.PrintWriter.print(PrintWriter.java:392)
>> at java.io.PrintWriter.println(PrintWriter.java:529)
>> at java.lang.Throwable.printStackTrace(Throwable.java:509)
>> at java.sql.SQLException.<init>(SQLException.java:103)
>> at
>> org.postgresql.util.PSQLException.<init>(PSQLException.java:19)
>> at
>> org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Conn
>> e
>> c
>> tion.java:480)
But I think I tracked it down...
The PSQLException constructor that is being used is
public PSQLException(String error)
{
super();
translate(error, null);
}
which does not set the 'message' variable.. Then the toString() of
PSQLException is:
public String toString()
{
return message;
}
so that is returning null.. and the cause of the NPE. I see the bug is
fixed in CVS :)
thanks for the help!
-pete
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Stephenson | 2003-07-29 16:27:01 | Re: NPE in creating a SQLException |
Previous Message | Scot P. Floess | 2003-07-29 15:50:08 | Re: NPE in creating a SQLException |