Announcement Announcement Module
No announcement yet.
Connection pooling Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Connection pooling

    I can't tell if I have my connection pooling setup right or not. Does anyone know how to test this?

    The behavior I'm seeing is this. If I have my number of initial poolable connections set to 1. It will always remain 1 (the max is 8), I'll never see a new connection started no matter how repeatedly I click refresh (I would expect it to add more, but maybe not). If I raise the number of initial threads to 4, it will start me with 4 and if I repeatedly click refresh I'll see that they seem to be being used at different times (some of the sleep values will reset like they've recently been used) and then they all go back to sleep. They never timeout and I still never see new one's created.

    It doesn't seem like I ever run out of connections in my pool, but it might just be because it's only ever using one connection.

    Below is my persistence.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""

       <bean id="myDataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">
          <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
          <property name="url" value="jdbc:mysql://localhost:3306/xxxxxxx"/>
          <property name="username" value="xxxxxx"/>
          <property name="password" value="xxxxxx"/>
          <property name="initialSize" value="1" />
          <property name="maxActive" value="8" />
          <property name="maxIdle" value="8" />
          <property name="maxWait" value="10000" />
          <property name="removeAbandoned" value="true" />
          <property name="removeAbandonedTimeout" value="60" />
          <property name="logAbandoned" value="true" />
       <bean id="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
          <property name="dataSource" ref="myDataSource"/>
          <property name="annotatedClasses">
          <property name="hibernateProperties">
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.max_fetch_depth">3</prop>
                <prop key="format_sql">true"</prop>
                <prop key="use_sql_comments">true</prop>
       <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
          <property name="sessionFactory" ref="mySessionFactory" />
       <tx:annotation-driven transaction-manager="txManager"/> 
       <bean id="BlogDAOImpl" class="">
           <property name="factory" ref="mySessionFactory" />
       <bean id="UserDAOImpl" class="">
           <property name="factory" ref="mySessionFactory" />
       <bean id="CommentDAOImpl" class="">
           <property name="factory" ref="mySessionFactory" />
    Is this how it's supposed to work or do I have something incorrect in my setup?

    Thanks in advance.

  • #2
    There is nothing wrong with it.

    Why should a refresh trigger a new connection? The page is rendered after that the connection is available again. If you really want to test it you need to do some load testing and that is not something you do by pressing refresh in your single browser.