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"); } }
原文:https://www.cnblogs.com/kikyoqiang/p/11788942.html