0
点赞
收藏
分享

微信扫一扫

jdbctemplate

忍禁 2023-03-05 阅读 61


xml配置

<!-- 数据匹配测试 -->
<bean id="test" class="com.taobao.tddl.client.jdbc.TDataSource"
init-method="init">
<property name="appName" value="test" />
<property name="dynamicRule" value="true" />
</bean>
<!--jdbc 模板-->
<bean id="template" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<constructor-arg ref="billDs"/>
</bean>

<bean id="billDAO" class="TDDLTEST.dao.impl.BillDAOImpl">
<property name="simpleJdbcTemplate" ref="template"></property>

</bean>

测试代码

ApplicationContext context = new ClassPathXmlApplicationContext("tddl.xml");
BillDAO billDAO = (BillDAO) context.getBean("billDAO");
System.out.println(billDAO.getFee(3688851005L,4070020L));


举报

相关推荐

0 条评论