Announcement Announcement Module
Collapse
No announcement yet.
How to know size of connection pool? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to know size of connection pool?

    ApplicationContext snippet:
    <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName">
    <value>org.hsqldb.jdbcDriver</value>
    </property>
    <property name="url">
    <value>jdbc:hsqldb:hsql://localhost/sa</value>
    </property>
    <property name="username">
    <value>sa</value>
    </property>
    <property name="password">
    <value>sa</value>
    </property>
    </bean>
    How to know size of connection pool? Is it possible to specify the size of connection pool?

  • #2
    Re: How to know size of connection pool?

    Originally posted by borland2004
    How to know size of connection pool? Is it possible to specify the size of connection pool?
    You did not specify a pool, so there is no size. If you want to use connection pooling, you might consider using org.apache.commons.dbcp.BasicDataSource. There you can configure pooling options as well. It can also easily be configured with Spring.

    Regards,
    Andreas

    Comment


    • #3
      Re: How to know size of connection pool?

      Originally posted by Andreas Senft
      You did not specify a pool, so there is no size. If you want to use connection pooling, you might consider using org.apache.commons.dbcp.BasicDataSource. There you can configure pooling options as well. It can also easily be configured with Spring.

      Regards,
      Andreas
      Thank you for your reply. That means i can set up connection pool with hibernate properties in spring, is it correct?

      Sometimes i need to specify connection number in connection pool because of performance.

      Best Regards

      Comment


      • #4
        The connection pool has nothing to do with Hibernate. To configure Hibernate's SessionFactory you need a DataSource. The DataSource itself can (internally) pool connections, such as the one I proposed. Hibernate will benefit from connection pooling, if it's available, but it will not know about it.

        If you use an application server, you can also obtain a preconfigured DataSource from JNDI which uses the application server's connection pool.

        Here is an example for a DBCP datasource configuration. I hope it helps:
        Code:
            <bean id="DataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
                <property name="driverClassName">
                    <value>$&#123;jdbc.driverClassName&#125;</value>
                </property>
                
                <property name="url">
                    <value>$&#123;jdbc.url&#125;</value>
                </property>
                
                <property name="username">
                    <value>$&#123;jdbc.username&#125;</value>
                </property>
                
                <property name="password">
                    <value>$&#123;jdbc.password&#125;</value>
                </property>
        
                <property name="poolPreparedStatements">
                    <value>true</value>
                </property>
                
                <property name="initialSize">
                    <value>1</value>
                </property>
                
                <property name="maxActive">
                    <value>5</value>
                </property>
                
                <property name="maxIdle">
                    <value>2</value>
                </property>
            </bean>
        Regards,
        Andreas

        Comment

        Working...
        X