首页 > 数据库技术 > 详细

ApacheDbUtilsUpdate

时间:2019-11-03 21:17:57      阅读:64      评论:0      收藏:0      [点我收藏+]
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");
    }

}

 

ApacheDbUtilsUpdate

原文:https://www.cnblogs.com/kikyoqiang/p/11788942.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!