File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes connection pooling in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "connection pooling in struts" Watch "connection pooling in struts" New topic
Author

connection pooling in struts

anita dhar
Ranch Hand

Joined: May 24, 2007
Posts: 34
how connection pooling works and what is the need of it where we are using this
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

"Connection Pooling" - Can you infer some meaning by the term itself anitha?

No matter its right or wrong, please let us know what you can guess by just spelling it out! Atleast What could it be?


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
anita dhar
Ranch Hand

Joined: May 24, 2007
Posts: 34
what i understand is connection pooling helps to manage and control dadabase connections from the jsp/servlets where we are store information between cleint request
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

Hi Anitha,


what i understand is connection pooling helps to manage and control dadabase connections from the jsp/servlets where we are store information between cleint request


Yeah thats correct. But the connections are not restricted to jsp/servlets - any part of application which needs a connection to the database.

Pool - You can think of a refrigerator.
Pooling - Think of keeping the items when you are not in need or once you are done with the stuff in the fridge.

Pooling is a general term used to store/keep the things in a common place wherein every resource which needs the stored item, gets one if available.

Connection Pooling applies to the Connection as its the object to be stored. You can customize or specify the total number of items (here connections) to be stored.

Advantages:
----------

You dont need to obtain a connection afresh everytime you need. Because obtaining connection is indeed a resource expensive - interms of time, network etc. Instead you just make use of the already obtained connection whenever you need. As many resources may be requiring the connection, its a best practice that soon after you are done with your job, close the connection, which will automatically add the released connection instance to the pool.

One good thing is that the Application Developers don't need to dig much in implementing this stuff. Thats why the Containers are there You just create a connnection pool with the appropriate details about the database, driver etc, and specify the number of connection instances to be maintained in the pool.


Hope this Helps.
anita dhar
Ranch Hand

Joined: May 24, 2007
Posts: 34
i got the concept , but not in the proper manner .this is right we are creating a no of instance pooling connections and contanier will perform other works .but i am still in cofusion
becaoz during my interviews i am not able to clearify this concept
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

No, we just specify the details for the Container to create the connections and maintain them in the pool.

The details are for obtaining the connection - database name, driver type, driver url,driver class, username, password etc.

The details for the connection pool - the no of instances it can keep at a time.

Mostly during the startup of the Application Server where the Container resides, it creates the connection instances and keep them in pool.

HtH.
[ May 24, 2007: Message edited by: Raghavan Muthu ]
anita dhar
Ranch Hand

Joined: May 24, 2007
Posts: 34
one class instance processes all clients request in a separate thread , and connection pool is a class with a number of jdbc Connection .When we are specify the size of your connection pool according to your resources where we are using the size
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

We will not use the class ConnectionPool, instead 'DataSource' which has the methods to provide you the connection from the pool.

The size what you configure is the input for the Container to create that many number of connetions to put in the pool.

We * DONT USE the size * except mentioning it during the configuration of connection pool details. Container will take care of the rest.
[ May 25, 2007: Message edited by: Raghavan Muthu ]
anita dhar
Ranch Hand

Joined: May 24, 2007
Posts: 34
can you tell me brief about the working of connection pooling
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

Hi Anitha,

I believe these URLs might be helpful to you to certain extent.

  • Connection Pooling - from Sun
  • Improved Performance with a Connection Pool
  • What is Connection Pooling?
  • Dive into Connection Pooling with J2EE



  • HtH.
    [ May 25, 2007: Message edited by: Raghavan Muthu ]
    anita dhar
    Ranch Hand

    Joined: May 24, 2007
    Posts: 34
    can inner class can be used in any class
    Rahul Bhattacharjee
    Ranch Hand

    Joined: Nov 29, 2005
    Posts: 2300
    Originally posted by anita dhar:
    how connection pooling works and what is the need of it where we are using this


    Creation of database connection is a costly affair.So its better to make a bunch of connections and hand out that to requestors on request.

    Once the need of the requestor is over then the requestor can return the connection to the pool by using the close method.
    That connection object can be used my many other threads later on.

    For reference you might want to check with some servlet container or J2EE vendor documentation for more information as how to configure datasource for that vendor.

    check this page for doing so for Tomcat 5.5.


    Rahul Bhattacharjee
    LinkedIn - Blog
     
    I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
     
    subject: connection pooling in struts
     
    Similar Threads
    Questions on EJB
    Connection Pooling
    Driver Loading
    servlet destroy method and session
    pooling in tomcat 6.x