以下是beans.xml(applicationContent.xml)
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations">
<list>
<value>classpath:jdbc.properties</value>
<value>classpath:email.properties</value>
</list>
</property>
</bean>
<bean id="proxoolDataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver" value="${jdbc.driverClassName}"/>
<property name="driverUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<!-- 测试的SQL执行语句 -->
<property name="houseKeepingTestSql" value="select AD"/>
<!-- 最少保持的空闲连接数 (默认2个) -->
<property name="prototypeCount" value="2"/>
<!-- proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁 默认30秒)
<property name="houseKeepingSleepTime" value="30"/> -->
<!-- 最大活动时间(超过此时间线程将被kill,默认为5分钟)
<property name="maximumActiveTime" value=""/>-->
<!-- 连接最长时间(默认为4个小时)
<property name="maximumConnectionLifetime" value="${proxool.maximumConnectionLifetime}"/>-->
<!-- 最小连接数 (默认2个)
<property name="minimumConnectionCount" value="${proxool.minimumConnectionCount}"/>-->
<!-- 最大连接数 (默认5个)
<property name="maximumConnectionCount" value="${proxool.maximumConnectionCount}"/> -->
<!--
<property name="statistics" value="${proxool.statistics}"/>-->
<!-- 别名
<property name="alias" value="${proxool.alias}"/> -->
<!--
<property name="simultaneousBuildThrottle" value="${proxool.simultaneous-build-throttle}"/>-->
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="proxoolDataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.ECWeb.model</value>
</list>
</property>
</bean>
web.xml(测试servlet)
<servlet>
<servlet-name>pooladmin</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>pooladmin</servlet-name>
<url-pattern>/pooladmin</url-pattern>
</servlet-mapping>
因为才疏学浅,和时间的问题,没有具体测试,只是简单的测试,连接成功,连接池的配置也是默认数据,
网上有很多都是要配置beans.xml和proxool.xml,还要配置web.xml,但是我觉得,配置proxool.xml也是为了给beans.xml做服务,现在我把proxool的配置直接在beans做配置,然后注入sessionFactory,也可以直接使用,所以我没有配置proxool.xml,至于web.xml我也觉得它最大的用处是,没有spring集成,才要在这配置,和它可以配置测试proxool的servlet(proxool自带的),我也觉得那个测试很好,但是因为各种问题,我没有测试,求某位大神,给及指导。。。如何在ssh2环境下,调用proxool自带的测试..
如果有哪位大神,看到有错误,或者不对,请一定要多多指教,感激不尽.....
附上:c3p0配置(未测试,不知道有没有启动连接池)
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.c3p0.acquireRetryAttempts">30</prop>
<prop key="hibernate.c3p0.acquireIncrement">2</prop>
<prop key="hibernate.c3p0.checkoutTimeout">30000</prop>
<prop key="hibernate.c3p0.idleConnectionTestPeriod">120</prop>
<prop key="hibernate.c3p0.maxIdleTime">180</prop>
<prop key="hibernate.c3p0.initialPoolSize">3</prop>
<prop key="hibernate.c3p0.maxPoolSize">50</prop>
<prop key="hibernate.c3p0.minPoolSize">1</prop>
<prop key="hibernate.c3p0.maxStatements">0</prop>
<prop key="hibernate.c3p0.validate">true</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.bang.model</value>
</list>
</property>
</bean>