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 all, I wish to know whether there is any limit to the number of connections,statements,resultsets that can exist in a simple bean which is accessed by a JSP file. Is it a good practice to initiate a connection to Database in the constructor of the class used as a bean? Thanks in advance, Rk
I think that there is a limit that depends on the maximum open cursors possible in the database. For example Oracle. Connection pooling is a good option. Often I think memory leaks can create problems with the maximum limit on open cursor exceeding. Prash
Originally posted by Rkrishna daruri: Is it a good practice to initiate a connection to Database in the constructor of the class used as a bean?
Probably not if you then put the bean into a web session. However, if there is only one bean in your application, or if the bean has application scope, or if your application has only a small number of simutaneous users, it should be OK. It's probably better practice to use connection pooling. That way, the same database connection can be used to service multiple simultaneous users. And multiple beans. The default limit for Oracle is between 50 and 100 connections (I think). The Oracle system uses some half dozen of these connections before you ever get started. If you had a session bean which made a connection in its constructor, you would use an additional connection for every instance of this bean. When you hit the limit, your bean will throw an Exception in its constructor (which may not be a good design for a bean). Your administrator can increase this limit to many thousands if required. But if you use connection pooling, you will be able to control the limits through your pool manager.