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

}

 

posted @ 2019-11-03 20:33  一只桔子2233  阅读(123)  评论(0编辑  收藏  举报