Results 1 to 4 of 4

Thread: How exactly does the database connection pooling works ?

  1. #1

    Default How exactly does the database connection pooling works ?

    I am using Spring ORM (2.5.6) with hibernate (3.3.2.GA). For the database connection pooling i have used c3p0 (0.9.1.2) with oracle 10g.

    Can anyone explain me how exactly the connection pooling works ? As per my knowledge we cannot have a connection open for a long period of time. It's generally preferred to open a connection, do the transaction and then close it.

    I was looking at the c3p0 implementation (com.mchange.v2.c3p0.ComboPooledDataSource). It uses the javax.sql.PooledConnection ?

    Can anyone please explain how exactly is the PooledConnection implemented ?

    Thanks in advance.

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello Shailesh

    Have read the documentation from the same C3P0 and its API?
    it is not related with Spring itself

    As per my knowledge we cannot have a connection open for a long period of time. It's generally preferred to open a connection, do the transaction and then close it.
    Thats the reason to know how configure well many properties of C3P0, how idle, minimum and max connections etc
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3

    Default

    Hi Dr_Pompeii,

    Thanks for your response.

    Yes, i know that the connection pooling (c3p0) is independent of spring.

    I have also configured all the properties (max/min pool size, maxStatements, idle time, etc) for the connection pool.

    My question was that though the configuration specifies a pool size and other details does it really maintain a live active connection pool (i.e implementation of the javax.sql.PooledConnection interface) or are the connections swapped when required.

    If the connections are pooled and are active till the timeout period then what happens when the connection expires ?

    Will the implementation swap a new connection to maintain the pool size or somehow recycle the expired connection object ?

    Sorry, in case i am getting too much into the vendor specific implementation.

    Thanks in advance.

  4. #4
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello

    My question was that though the configuration specifies a pool size and other details does it really maintain a live active connection pool (i.e implementation of the javax.sql.PooledConnection interface) or are the connections swapped when required.
    is logic work with the JDBC API in the low/deeper level

    If the connections are pooled and are active till the timeout period then what happens when the connection expires ?
    I am not an expert, but I could assume that some exception could be throw or perhaps other connection from the pool could be re used

    Will the implementation swap a new connection to maintain the pool size or somehow recycle the expired connection object ?
    Could be

    Sorry, in case i am getting too much into the vendor specific implementation.
    Don't worry, but I suggest you friendly read the API, there should does mention about if some exception should be throw or not, BTW exists Forum for C3PO? If yes you can get some support there

    HTH
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •