jdbctemplate

来源:互联网 发布:联想电脑桌面必备软件 编辑:程序博客网 时间:2024/05/22 16:44

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));