zoukankan      html  css  js  c++  java
  • spring JdbcTemplate数据库

    DAO

    package DAO;
    
    import org.springframework.jdbc.core.JdbcTemplate;
    
    public class OrderDao {
        private JdbcTemplate jdbcTemplate;
    
        public JdbcTemplate getJdbcTemplate() {
            return jdbcTemplate;
        }
    
        public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
            this.jdbcTemplate = jdbcTemplate;
        }
        public  int  addOrder(String outTradeNo,String subject,String totalAmount,String authcode){
            String sql ="insert into orders(outTradeNo,subject,totalAmount,authcode) values(?,?,?,?)";
            int ret = jdbcTemplate.update(sql, new String[]{outTradeNo,subject,totalAmount,authcode});
            return ret;
        }
    }
    

    POJO

     private String outTradeNo;
        private String subject;
        private String totalAmount; 
        private String authCode; 
    SET/GET
    

    service

    package service;
    
    import DAO.OrderDao;
    
    public class OrderService {
    
        private OrderDao orderDao;
    
        public void setOrderDao(OrderDao orderDao) {
            this.orderDao = orderDao;
        }
    
        public boolean order(String outTradeNo,String subject,String totalAmount,String authCode){
            int ret = orderDao.addOrder(outTradeNo,subject,totalAmount,authCode);
            if(ret>0) return true;
            return false;
        }
    }
    

    applicationContex.xml

    
        <!--配置数据库信息-->
        <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/paydb"/>
            <property name="username" value="root"/>
            <property name="password" value="root"/>
        </bean>
    
        <!--定义spring数据库模板-->
        <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
            <property name="dataSource" ref="dataSource"/>
        </bean>
        <!--注册DAO组件 使用依赖注入jdbcTemplate-->
        <bean id="OrderDao" class="DAO.OrderDao">
            <property name="jdbcTemplate" ref="jdbcTemplate"/>
        </bean>
    
  • 相关阅读:
    超分网络一般不需要BN
    常用的损失函数loss
    VS Code导入torch后出现红色下划线警告
    光流算法:Horn–Schunck光流讲解
    网络训练loss不下降的问题
    l1,l2loss的比较
    Nvidia DALI加速数据增强
    pytorch将部分参数进行加载
    模型训练技巧
    node 特性及优缺点
  • 原文地址:https://www.cnblogs.com/zhaocundang/p/9726408.html
Copyright © 2011-2022 走看看