well problem guys.... I have developed a kind of online quiz...which works perfectly with single user...but if two requests come at the same time...we face a unsual problem the first person gets this message.... java.sql.SQLException: Invalid state for getResultSet and the second user gets this message..... java.sql.SQLException: [Microsoft][ODBC Driver Manager] Function sequence error
well I m surprised at it becoz i have created session object thinking that this conflict wont happen but i m not able to understand this... can u help me maha anna ,william.....please
Maybe you should use a connection broker for your database connections you can get one at http://www.javaexchange.com ------------------ In Gates we trust. Yeah right....
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
If I understood your question correctly, then yes, you do need a new ResultSet and Statement instance for each query. If you are "sharing" a ResultSet variable (for example, as an attribute in your Servlet class) the second query will overwrite anything returned by the first query, and who knows what will happen next. Hope this helps. - Rick
Just to restate one of the most important things about servlet programming. It is very dangerous to have any non-final member variables in a servlet class. If you have any, at all, move them out to somewhere which is not shared betwen requests, or you will face all sorts of wierd faults.
Originally posted by Frank Carver: [...] It is very dangerous to have any non-final member variables in a servlet class. If you have any, at all, move them out [...]
Or, implement SingleThreadModel, but beware of the scalability issues of that. (And, as Frank pointed out elsewhere, your resources such as database connections will eventually time out, so be prepared to check and if necessary resurrect them when servicing a request).
[This message has been edited by Peter den Haan (edited March 06, 2001).]
Joined: Feb 03, 2001
I don't know if it's possible with your appserver but consider using connection pooling. I know it's easy to set up in Websphere and JRun.
Yeah , this is the problem with Connection object though u can solve with connection pool class which maintains the pool of connection objects. It can be prepared by urself(or search in net for sample code) irrespective of application server u use.