日期:2014-05-17  浏览次数:20648 次

请大牛帮忙看下这个配置有问题吗
XML code

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
         
         <property name="url" value="jdbc:jtds:sqlserver://192.168.0.133:1433;DatabaseName=cc"/>
        <property name="username" value="cc"/>
         <property name="password" value="cc"/>
         <!-- Connection Pooling Info -->
  <property name="initialSize" value="5" />
  <property name="maxActive" value="100" />
  <property name="maxIdle" value="30" />
  <property name="maxWait" value="1000" />
  <property name="poolPreparedStatements" value="true" />
  <property name="defaultAutoCommit" value="false" />
    </bean>



费解啊 只要加上
XML code
  
<property name="initialSize" value="5" />
  <property name="maxActive" value="100" />
  <property name="maxIdle" value="30" />
  <property name="maxWait" value="1000" />
  <property name="poolPreparedStatements" value="true" />
  <property name="defaultAutoCommit" value="false" />

就有问题 去掉 就可以正常运行

------解决方案--------------------
这个我没接触过,帮顶下吧。
------解决方案--------------------
楼主 你用错了!
给你看一段关于这个类的用途吧
NOTE: This class is not an actual connection pool; it does not actually pool Connections. It just serves as simple replacement for a full-blown connection pool, implementing the same standard interface, but creating new Connections on every call. 

org.springframework.jdbc.datasource.DriverManagerDataSource不包含一下属性,当然你就不能注入了
 <!-- Connection Pooling Info -->
 <property name="initialSize" value="5" />
 <property name="maxActive" value="100" />
 <property name="maxIdle" value="30" />
 <property name="maxWait" value="1000" />
 <property name="poolPreparedStatements" value="true" />
 <property name="defaultAutoCommit" value="false" />


你如果要用连接池: 你可以用DHCP 或者 C3PO的数据源

 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/news"/>
<property name="username" value="root"/>
<property name="password" value="1234"/>
<property name="maxActive" value="20"/>
<property name="maxIdle" value="10"/>
<property name="initialSize" value="1"/>
<property name="maxWait" value="1000"/>
<property name="defaultAutoCommit" value="true"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value=