Thread: Help with NPE

Help with NPE

From
"M. A. Sridhar"
Date:
Hello folks,

I'm getting this NullPointerException from within the PostgreSQL JDBC driver,
and I'm not sure what to make of it:

java.lang.NullPointerException
    at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:62)
    at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:497)
    at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:320)
    at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
    at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:153)
    at
zerocode.udm.PreparedStmtWithSql.executeQuery(PreparedStmtWithSql.java:175)
    at zerocode.udm.DbObjectStore._retrieveWithOptSql(DbObjectStore.java:1562)
....

This seems to happen not immediately at application startup, but some time
thereafter. When I first connect to the database, everything is fine, but
after I leave the app idle for a while and use it again, it crashes. This
could well be because there is something in my code base that keeps an open
connection around for a while, but I was hoping for a more informative
message if that were the case (such as "connection expired") instead of an
NPE.

I would greatly appreciate any help on this one.

Thanks.

=====
------
M. A. Sridhar
m_a_sridhar@yahoo.com

__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

Re: Help with NPE

From
"David Hooker"
Date:
This is because you tried to use a Connection that was closed.  I agree
that something other than a NPE should be thrown in this case.

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of M. A. Sridhar
Sent: Sunday, November 10, 2002 8:56 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] Help with NPE


Hello folks,

I'm getting this NullPointerException from within the PostgreSQL JDBC
driver,
and I'm not sure what to make of it:

java.lang.NullPointerException
    at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:62)
    at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connec
tion.java:497)
    at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Stateme
nt.java:320)
    at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stateme
nt.java:48)
    at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1St
atement.java:153)
    at
zerocode.udm.PreparedStmtWithSql.executeQuery(PreparedStmtWithSql.java:1
75)
    at
zerocode.udm.DbObjectStore._retrieveWithOptSql(DbObjectStore.java:1562)
....

This seems to happen not immediately at application startup, but some
time
thereafter. When I first connect to the database, everything is fine,
but
after I leave the app idle for a while and use it again, it crashes.
This
could well be because there is something in my code base that keeps an
open
connection around for a while, but I was hoping for a more informative
message if that were the case (such as "connection expired") instead of
an
NPE.

I would greatly appreciate any help on this one.

Thanks.

=====
------
M. A. Sridhar
m_a_sridhar@yahoo.com

__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


Re: Help with NPE

From
Barry Lind
Date:
I checked in a patch that produces a better error message when this
situation arises.

--Barry


David Hooker wrote:
> This is because you tried to use a Connection that was closed.  I agree
> that something other than a NPE should be thrown in this case.
>
> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of M. A. Sridhar
> Sent: Sunday, November 10, 2002 8:56 PM
> To: pgsql-jdbc@postgresql.org
> Subject: [JDBC] Help with NPE
>
>
> Hello folks,
>
> I'm getting this NullPointerException from within the PostgreSQL JDBC
> driver,
> and I'm not sure what to make of it:
>
> java.lang.NullPointerException
>     at
> org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:62)
>     at
> org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connec
> tion.java:497)
>     at
> org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Stateme
> nt.java:320)
>     at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stateme
> nt.java:48)
>     at
> org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1St
> atement.java:153)
>     at
> zerocode.udm.PreparedStmtWithSql.executeQuery(PreparedStmtWithSql.java:1
> 75)
>     at
> zerocode.udm.DbObjectStore._retrieveWithOptSql(DbObjectStore.java:1562)
> ....
>
> This seems to happen not immediately at application startup, but some
> time
> thereafter. When I first connect to the database, everything is fine,
> but
> after I leave the app idle for a while and use it again, it crashes.
> This
> could well be because there is something in my code base that keeps an
> open
> connection around for a while, but I was hoping for a more informative
> message if that were the case (such as "connection expired") instead of
> an
> NPE.
>
> I would greatly appreciate any help on this one.
>
> Thanks.
>
> =====
> ------
> M. A. Sridhar
> m_a_sridhar@yahoo.com
>
> __________________________________________________
> Do you Yahoo!?
> U2 on LAUNCH - Exclusive greatest hits videos
> http://launch.yahoo.com/u2
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>



Re: Help with NPE

From
"M. A. Sridhar"
Date:
Thanks for your inputs, folks. I did find the problem in my code, and as
David said, it was because of an attempt to use a closed connection.

Thanks again.

--- Barry Lind <blind@xythos.com> wrote:
> I checked in a patch that produces a better error message when this
> situation arises.
>
> --Barry
>
>
> David Hooker wrote:
> > This is because you tried to use a Connection that was closed.  I agree
> > that something other than a NPE should be thrown in this case.
> >
> > -----Original Message-----
> > From: pgsql-jdbc-owner@postgresql.org
> > [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of M. A. Sridhar
> > Sent: Sunday, November 10, 2002 8:56 PM
> > To: pgsql-jdbc@postgresql.org
> > Subject: [JDBC] Help with NPE
> >
> >
> > Hello folks,
> >
> > I'm getting this NullPointerException from within the PostgreSQL JDBC
> > driver,
> > and I'm not sure what to make of it:
> >
> > java.lang.NullPointerException
> >     at
> > org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:62)
> >     at
> > org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connec
> > tion.java:497)
> >     at
> > org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Stateme
> > nt.java:320)
> >     at
> > org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stateme
> > nt.java:48)
> >     at
> > org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1St
> > atement.java:153)
> >     at
> > zerocode.udm.PreparedStmtWithSql.executeQuery(PreparedStmtWithSql.java:1
> > 75)
> >     at
> > zerocode.udm.DbObjectStore._retrieveWithOptSql(DbObjectStore.java:1562)
> > ....
> >
> > This seems to happen not immediately at application startup, but some
> > time
> > thereafter. When I first connect to the database, everything is fine,
> > but
> > after I leave the app idle for a while and use it again, it crashes.
> > This
> > could well be because there is something in my code base that keeps an
> > open
> > connection around for a while, but I was hoping for a more informative
> > message if that were the case (such as "connection expired") instead of
> > an
> > NPE.
> >
> > I would greatly appreciate any help on this one.
> >
> > Thanks.
> >
> > =====
> > ------
> > M. A. Sridhar
> > m_a_sridhar@yahoo.com
> >
> > __________________________________________________
> > Do you Yahoo!?
> > U2 on LAUNCH - Exclusive greatest hits videos
> > http://launch.yahoo.com/u2
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> >     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> >
>
>


=====
------
M. A. Sridhar
m_a_sridhar@yahoo.com

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com