java spring bonecp 的问题
各位高手好刚折腾java, 头脑中的问号好多啊
现在在折腾spring+bonecp 的问题
我在spring-serverlet.xml中这样配置的(其实是从网上copy的):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.web.controller" />
<mvc:interceptors>
<bean class="com.web.base.Filter" />
</mvc:interceptors>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<ref local="bonecpDataSource" />
</property>
</bean>
<bean id="bonecpDataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ticket" />
<property name="username" value="root" />
<property name="password" value="nimei" />
<property name="idleConnectionTestPeriod" value="60" />
<property name="idleMaxAge" value="240" />
<property name="maxConnectionsPerPartition" value="30" />
<property name="minConnectionsPerPartition" value="10" />
<property name="partitionCount" value="3" />
<property name="acquireIncrement" value="5" />
<property name="statementsCacheSize" value="100" />
<property name="releaseHelperThreads" value="3" />
</bean>
</beans>
但接下来怎么弄,如何和spring中的jdbctemplate结合呢?
请高手写个简单的和jdbctemplate结合的小程序
或者是给个思路,谢谢
bonecp spring jdbctemplate --------------------编程问答-------------------- 好贴要先顶起来 --------------------编程问答-------------------- <!--1:配置一个JdbcTemplate实例,并将这个“共享的”,“安全的”实例注入到不同的DAO类中去-->
<bean id = "jdbcTemplate"
class = "org.springframework.jdbc.core.JdbcTemplate">
<property name = "dataSource" ref="dataSource"/>
</bean>
在然后就可以在dao中引用这个了
<bean id = "actorJdbcTemplateDao"
class = "com.lo易做图.bo.dao.impl.ActorJdbcTemplateDaoImpl">
<property name="jdbcTemplate" ref="jdbcTemplate"/>
</bean> --------------------编程问答-------------------- jdbctemplate不推荐吧,建议用spring data来做
补充:Java , Java EE