- import java.sql.SQLException;
- import org.apache.commons.dbutils.QueryRunner;
- /*
- * 使用DBUtils技术 完成 往sort表中 修改数据的操作
- * s006 清洁用品 商品名称修改为 威猛先生
- */
- public class UpdateDemo {
- public static void main(String[] args) throws SQLException {
- //1.获取QueryRunner对象
- QueryRunner qr = new QueryRunner(DBCPUtils.getDataSource());
- //2.执行sql语句
- String sql = "update sore set sname = ? where sid = ?";
-
- Object[] params = {"威猛先生","s006"};
- //往表中增加数据的操作
- int line = qr.update(sql,params);
- //3.处理结果
- System.out.println("本次操作影响的行数为:"+line+"行。");
- }
- }
复制代码 |
|