Re: NPE in creating a SQLException
От | Csaba Nagy |
---|---|
Тема | Re: NPE in creating a SQLException |
Дата | |
Msg-id | 1059496838.18438.31.camel@coppola.ecircle.de обсуждение исходный текст |
Ответ на | Re: NPE in creating a SQLException (Peter Royal <proyal@pace2020.com>) |
Список | 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 >
В списке pgsql-jdbc по дате отправления: