質問

I am trying to implement connection pooling in my Hibernate/Spring webservice, the config is as follows.

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close">
    <property name="driverClassName" value="${dataSource.driverClassName}" />
    <property name="url" value="${dataSource.url}"/>
    <property name="username" value="${dataSource.username}"/>
    <property name="password" value="${dataSource.password}"/>
<!--
    <property name="timeBetweenEvictionRunsMillis" value="1800000"/>
    <property name="numTestsPerEvictionRun" value="3"/>
    <property name="minEvictableIdleTimeMillis" value="1800000"/>
    <property name="initialSize" value="3"/>
    <property name="maxActive" value="10"/>
    <property name="maxIdle" value="10"/>
    <property name="maxWait" value="5000"/>
    <property name="poolPreparedStatements" value="true"/>
    <property name="maxOpenPreparedStatements" value="100"/>
    <property name="testOnBorrow" value="true"/>
    <property name="testWhileIdle" value="true"/>
    <property name="testOnReturn" value="true"/>
    <property name="validationQuery" value="SELECT 1"/>
-->
</bean>
<!--ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc)--> 

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="annotatedClasses">
        <list>
            <value>com.limousine.domain.AddressDetails</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop> 
            <!--<prop key="hibernate.hbm2ddl.auto">create</prop>-->
        </props>
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean> 

But I am getting not getting connected exception.

正しい解決策はありません

他のヒント

You are using different versions of hibernate for creating Session Factory (hibernate4) and Transaction Manager (hibernate3). Make them use the same hibernate versions.

Use

org.springframework.orm.hibernate4.HibernateTransactionManager

and

org.springframework.orm.hibernate4.LocalSessionFactoryBean
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top