时间:2021-07-01 10:21:17 帮助过:34人阅读
实现类:
package com.learning.dao.impl; import java.sql.SQLException; import org.apache.commons.dbutils.QueryRunner; import com.learning.dao.AccountDao; import com.learning.util.C3P0Util; public class AccountDaoImpl implements AccountDao { public void updateAccount(String fromname, String toname, double money) throws Exception { //创建一个QueryRunner对象 QueryRunner qr = new QueryRunner(C3P0Util.getDataSource()); qr.update("update account set money=money-? where name=?",money,fromname); qr.update("update account set money=money+? where name=?",money,toname); } }
转账示例(一):Dao层面实现(本例采用QueryRunner来执行sql语句,数据源为C3P0)
标签:row set sql语句 class 接口 示例 query ring ram