From: | Csaba Nagy <nagy(at)ecircle-ag(dot)com> |
---|---|
To: | Peter Royal <proyal(at)pace2020(dot)com> |
Cc: | "Scot P(dot) Floess" <floess(at)mindspring(dot)com>, Postgres JDBC <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: NPE in creating a SQLException |
Date: | 2003-07-29 16:40:38 |
Message-ID: | 1059496838.18438.31.camel@coppola.ecircle.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Yep, that's it ! The toString method returning null...
Cheers,
Csaba.
On Tue, 2003-07-29 at 18:16, Peter Royal wrote:
> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andy Kriger | 2003-07-29 19:35:49 | SQL99 error codes |
Previous Message | Csaba Nagy | 2003-07-29 16:39:18 | Re: NPE in creating a SQLException |