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.
Hello, I am opening and closing connection for my each method in database bean. I have 2 questions Does this practice create performance problem? If yes Can someone tell me how to use connection pooling Thanks in Advance, - Girish
You should always close a connection as soon as your are finished with it - ignoring performance implications. And you should do the same even if you use connection pooling (though in this instance the connection is actually returned to the pool rather than closed).
Your code shouldn't change if you use connection pooling or not (assuming you are using a DataSource). Where are you getting your connection pooling implementation from?
How you implement one depends on what JDBC driver you are using. Some have it built in. What container you are using. Tomcat (and most other) containers has a container managed connection pool. You can also implement one yourself. There is good opensource implimentation here: http://jakarta.apache.org/commons/dbcp/
Check the documentation for your driver and servlet container. If you followed Paul's advice, you may already be using it.