隨筆-153  評論-235  文章-19  trackbacks-0
          參考:(willpower88兄的blog) http://www.aygfsteel.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 流浪汗 閱讀(2581) 評論(0)  編輯  收藏 所屬分類: Spring
          主站蜘蛛池模板: 五寨县| 迁安市| 余江县| 锡林浩特市| 肇庆市| 台江县| 辰溪县| 丰原市| 扶绥县| 杭州市| 梅州市| 额敏县| 无锡市| 石林| 罗定市| 岫岩| 宜城市| 昌江| 镇江市| 文化| 扎鲁特旗| 托里县| 临潭县| 揭阳市| 溧阳市| 昭通市| 东莞市| 和林格尔县| 梅州市| 锦州市| 望城县| 洞头县| 天峨县| 南昌市| 花莲县| 西宁市| 泽库县| 五原县| 临沂市| 宾川县| 岳阳市|