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