RE: Error in servlet - Mailing list pgsql-general

From Andreas Tille
Subject RE: Error in servlet
Date
Msg-id Pine.LNX.4.21.0009151023040.6463-100000@wr-linux02.rki.de
Whole thread Raw
In response to RE: Error in servlet  ("chris markiewicz" <cmarkiew@commnav.com>)
Responses RE: RE: Error in servlet  ("chris markiewicz" <cmarkiew@commnav.com>)
Re: RE: Error in servlet  (Peter Mount <peter@retep.org.uk>)
List pgsql-general
On Thu, 14 Sep 2000, chris markiewicz wrote:

> could this be a servlet/thread issue?  i cannot tell from the code snippet,
Solved.  I really stupidly forgot an rs.next() :-(((.

> 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.
Well, that might be true for query and rs and I'll change that, but
in my opinion

public class ServletSQLClass
{
  private Connection          con;
  private Statement           stmt;

  ...
  con = DriverManager.getConnection(url,user,passwd);
  stmt = con.createStatement();
  ...
}

con and stmt have to be class scope to hold the connection to the
database and don't have to reopen over and over.  Or did I understand
something wrong?

Kind regards

         Andreas.


pgsql-general by date:

Previous
From: Dale Walker
Date:
Subject: Re: vacuum taking long time
Next
From: Fernando Caamaño
Date:
Subject: load data from a file