RE: Error in servlet - Mailing list pgsql-general

From chris markiewicz
Subject RE: Error in servlet
Date
Msg-id 005601c01e68$1d051bc0$dbb846c6@cmarkiewicz
Whole thread Raw
In response to Error in servlet  (Andreas Tille <tillea@rki.de>)
Responses RE: Error in servlet
List pgsql-general
could this be a servlet/thread issue?  i cannot tell from the code snippet,
but remember that variables in a servlet with class scope are essentially
static.  (i am guessing that query, rs, stmt, etc are all class scope.  this
is very dangerous, in the programming sense of the word...)  i've had
similar (but not the same) problems before.  as a general rule, i NEVER put
a class scope variable in a servlet unless i really mean to.

chris

-----Original Message-----
From: pgsql-general-owner@hub.org [mailto:pgsql-general-owner@hub.org]On
Behalf Of Andreas Tille
Sent: Thursday, September 14, 2000 11:21 AM
To: PostgreSQL General
Subject: [GENERAL] Error in servlet


Hello,

is there any known reason for the following behaviour:

I wrote a servlet with several database accesses via stored functions
and select statements.  On a certain point of my servlet I get
the following:

[14/09/2000 16:31:51:216 CEST] Runtime.log:
org.postgresql.jdbc1.ResultSet@80ab4ff
[14/09/2000 16:31:51:217 CEST] java.lang.NullPointerException:
    at org.postgresql.jdbc1.ResultSet.getString(ResultSet.java)
    at WebSQL.pGetGroupMemberByLocation(WebSQL.java:484)
    at Web.DoWeb(Web.java:272)
    at ehec.service(ehec.java:24)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:311)
    at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
    at org.apache.jserv.JServConnection.run(JServConnection.java:188)
    at java.lang.Thread.run(Thread.java)

I try to give a short description of the critical function in
WebSQL.java:484

 -----  snip   ----

  public boolean pGetGroupMemberByLocation(Webdata data, int IdStandort,
                              String S_IdArbeitsgruppe, String
S_IdMitarbeiter)
  {
    try {
      query = "SELECT * FROM Mitarbeiter; " ;
      query = "SELECT count(*) As FName FROM standort; " ;

      query = "SELECT '<td class=\"MenuMain\"><a class=\"MenuMain\" href=\"'
|| '" +
              project.GetServletName()  + "' || '?" + "mid" +
              "=' || i.IdMenuShow || '&" + "tid" +
              "=' || i.IdWebSeite || '\">' || i.MenuItem || '</a></td>' " +
              "AS getmenu FROM   Menu m " +
              "INNER JOIN MenuItem i ON i.IdMenu = m.IdMenu  WHERE  m.IdMenu
= " + "54" +
          " ORDER BY i.Sort ; " ;
      rs = stmt.executeQuery(query);

if ( rs == null ) error.Common("Write message to logfile");
else error.Common("rs = " + rs); // This is the entry in Runtime.log
query = rs.getString(1);
error.Common("Are you living?");

 ----  snip ----

I tried different querys (see the strings "query").  First I reduced to
simple ones, later I used a more complex which worked inside the same
servlet some statements before and worked.  They show all the same
behaviour to fail with the NullPointerException.

I'm using PostgreSQL 7.0.2, Apache, Jserv.
The behaviour is the same using

  http://www.retep.org.uk/postgres/jdbc7.0-1.1.jar
  http://www.retep.org.uk/postgres/jdbc7.0-1.2.jar

as JDBC driver.

I'm really in desperation with this stupid problem and tried
two days to solve it but failed.  Any idea what might went wrong
here.  It is a problems of threads od anything else.  I can't see
any pointer which could be null here.

Really hoping for your help

           Andreas.


pgsql-general by date:

Previous
From: Richard Poole
Date:
Subject: "initdb -t" ate my baby
Next
From: "Bryan White"
Date:
Subject: Re: Corrupt Table