This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi guys! I just read about Tomcat's connectio pooling. I don't have any more questions about configuration right now... What I need to know is how to use the connection pool in my code. In the tomcat docs they had this snippet
But it doesn't give a clear explanation like how do I get a connection? The line below doesn't tell anything about this.
Also, would I happen to have a single object that does all database transactions such as insert, edit, delete. I have several methods in it. Would it be a wise idea to close the connection before the method ends or return a value? Or would it be better if I close the connection before the servlet forwards/redirects to a JSP or don't close the connection at all?
conn = ... get connection from connection pool ...
I believe you have created a datasource in Tomcat for connection pooling. If so, then to get the connection from the pool, you will do a lookup of the datasource and invoke the getConnection method on the Datasource object. Something like: