• ApacheDbUtilsUpdate


    ApacheDbUtilsUpdate
    package p1;
    
    import com.DataSourceUtil;
    import org.apache.commons.dbutils.QueryRunner;
    
    public class ApacheDbUtilsUpdate {
        public static void main(String[] args) throws Exception {
            // add();
            // update();
            delete();
        }
    
        public static int add() throws Exception {
            QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSourceC3p0());
            String sql = "insert into student values(?,?)";
            return queryRunner.update(sql, "4", "zl");
        }
    
        public static int update() throws Exception {
            QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSourceC3p0());
            String sql = "update student set name=? where id=?";
            return queryRunner.update(sql, "xx", "4");
        }
    
        public static int delete() throws Exception {
            QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSourceC3p0());
            String sql = "delete from student where id=?";
            return queryRunner.update(sql, "4");
        }
    
    }
  • 相关阅读:
    函数
    字符串格式化
    集合
    习题02
    int/str/list/tuple/dict必会
    元组/字典
    列表方法
    练习题(format、expandtabs、片层)
    字符串方法
    JMM
  • 原文地址:https://www.cnblogs.com/kikyoqiang/p/11788942.html
Copyright © 2020-2023  润新知