> Talking about STM (as jon said:), I have a question ...
> When I first started using servlets (and java), I used (the default)
> "implements MultipleThreadModel" and started getting problems when 2 users
> would "cross" the DB connection, i.e. one would open the query and the
> other would take over it... I then realized that on this model the servlets
> would be sharing the same "resource". So, I changed to SingleThreadModel to
> avoid the problem and all worked just fine, but looks like it was not the
> correct way to solve this problem.
> Could anyone elaborate or give me a link, so I could get more information
> about STMxMTM and how to work with both correctly?
The simple/best solution here is to use a cache of DB connections.
Here is what you do:
In your init() method, create a new pool object and fill that pool with
database connections.
In your service()/doGet()/doPost() method where you will need access to a
database connection, ask the pool object to provide you with a connection.
Make sure to release it back to the pool in a "finally" block so that
exceptions do not cause you to leave connections out of the pool.
So, where do you get that JDBC Connection pool? Well, there are a few good
ones listed here:
<http://c.clearink.com/index.htma?SCREEN=search&searchString=jdbc>
Thus, the only object declared as a global within your servlet is the Pool.
It is the responsibility of the Pool to manage the syncronization.
I hope that helps. I also suggest reading a book on syncronization.
-jon
----------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]