Re: NPE in creating a SQLException
От | Peter Royal |
---|---|
Тема | Re: NPE in creating a SQLException |
Дата | |
Msg-id | 01D0EBEF-C1E0-11D7-AC9E-000393B61B56@pace2020.com обсуждение исходный текст |
Ответ на | Re: NPE in creating a SQLException ("Scot P. Floess" <floess@mindspring.com>) |
Ответы |
Re: NPE in creating a SQLException
|
Список | 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
В списке pgsql-jdbc по дате отправления: