參考:(willpower88兄的blog)
http://www.tkk7.com/willpower88/archive/2007/01/10/92928.html當我spring中用c3p0時第一次老出現
org.hibernate.exception.JDBCConnectionException: could not execute query
刷新后就不會。一番折騰后直接用<property name="" value="" />就可以了。隨后找到willpower88兄的blog他總結得很好。
環境:
spring 2.0
c3p0-0.9.0.4
spring配置文件如下(引用willpower88兄的,注釋掉的都有問題的):
<bean?id="dataSource"?class="com.mchange.v2.c3p0.ComboPooledDataSource"???destroy-method="close">
?????????<property?name="driverClass"?value="com.mysql.jdbc.Driver"?/>
?????????<property?name="jdbcUrl"?value="jdbc:mysql://localhost/test"/>????????????
?????????<property?name="user"?value="root"/>
?????????<property?name="password"?value=""/>
??????????
?????????<property?name="minPoolSize"?value="2"/>
?????????<property?name="maxPoolSize"?value="20"/>
?????????<property?name="maxIdleTime"?value="1800"/>
?????????<property?name="acquireIncrement"?value="2"/>
?????????<property?name="maxStatements"?value="0"/>
?????????<property?name="initialPoolSize"?value="3"/>
?????????<property?name="idleConnectionTestPeriod"?value="1800"/>
?????????<property?name="acquireRetryAttempts"?value="30"/>
?????????<property?name="breakAfterAcquireFailure"?value="true"/>
?????????<property?name="testConnectionOnCheckout"?value="false"/>
?????????
?????????<!--?
?????????<property?name="properties">
??????????<props>??????????????
??????????????<prop?key="c3p0.minPoolSize">1</prop>?
??????????????<prop?key="c3p0.maxPoolSize">10</prop>?
??????????????<prop?key="c3p0.maxIdleTime">1800</prop>??????????????
??????????????<prop?key="c3p0.acquireIncrement">2</prop>?
??????????????<prop?key="c3p0.maxStatements">0</prop>?
??????????????<prop?key="c3p0.initialPoolSize">2</prop>
??????????????<prop?key="c3p0.idleConnectionTestPeriod">1800</prop>
??????????????<prop?key="c3p0.acquireRetryAttempts">30</prop>
??????????????<prop?key="c3p0.breakAfterAcquireFailure">true</prop>
??????????????<prop?key="c3p0.testConnectionOnCheckout">true</prop>
??????????????<prop?key="user">root</prop>
??????????????<prop?key="password">999999</prop>
??????????????
??????????</props>
?????????</property>
????????-->??????
</bean>
<!--?Hibernate?SessionFactory?-->
<bean?id="sessionFactory"?class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
??<property?name="dataSource"?ref="dataSource"/>
??<property?name="mappingDirectoryLocations">
??????<list>
???<value>classpath:/com/licaionline/domain/</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.generate_statistics">true</prop>
?????<prop?key="hibernate.connection.release_mode">auto</prop>??????????????????????
?????<prop?key="hibernate.autoReconnect">true</prop>
?????<prop?key="hibernate.cglib.use_reflection_optimizer">true</prop>
<!--?
????<prop?key="hibernate.useUnicode"></prop>?
????<prop?key="hibernate.characterEncoding"></prop>
????<prop?key="hibernate.default-lazy-init"></prop>
????<prop?key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>?????
?-->
????????????????????????????????
<!--
????<prop?key="hibernate.c3p0.acquire_increment">2</prop>
????<prop?key="hibernate.c3p0.idle_test_period">1800</prop>
????<prop?key="hibernate.c3p0.timeout">1800</prop>
????<prop?key="hibernate.c3p0.max_size">30</prop>
????<prop?key="hibernate.c3p0.min_size">2</prop>
????<prop?key="hibernate.c3p0.max_statements">50</prop>
-->?????????
???</props>
??</property>
</bean>
posted on 2007-03-18 17:06
流浪汗 閱讀(2576)
評論(0) 編輯 收藏 所屬分類:
Spring