• Post Reply Bookmark Topic Watch Topic
  • New Topic

connection pooling in struts  RSS feed

 
anita dhar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how connection pooling works and what is the need of it where we are using this
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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?
 
anita dhar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you tell me brief about the working of connection pooling
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 34
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    can inner class can be used in any class
     
    Rahul Bhattacharjee
    Ranch Hand
    Posts: 2308
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!