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.