I've read all the
tomcat docs on datasource connection pooling, and got it to work easily. However, I have a question.
My DAO code (some of it) looks something like this:
And then my
servlet might do this:
So the questions - are my connections being pooled? i.e., if I have a bunch of servlets that all create new DAO objects, run a query, and close the connection, does the connection just drop back into the pool? I think it does. However, isn't there a lot of overhead everytime a servlet needs to make a database query and constructs a new DAO object? Perhaps the DAO should be a singleton? Or maybe the lookup and the datasource.getConnection() just grabs a connection from the pool, so I'm fine?
Is it better to close the connection in the update() and select() methods, rather than require an explicit call to close?
I'm trying to understand this new design
pattern (for me) - any advice is appreciated.
Thanks!
[ July 04, 2005: Message edited by: Tom McAmmond ]