src/edu/school/dao/impl/AdminDaoImpl.java
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package edu.school.dao.impl;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import edu.school.dao.AdminDao;
import edu.school.entity.*;
import edu.school.utils.C3p0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
public class AdminDaoImpl implements AdminDao {
private QueryRunner runner=new QueryRunner(C3p0Utils.getDs());
//根据用户名和密码查询
public Admin queryByUsernameAndPwd(String username, String pwd) {
try {
return runner.query("select * from admin where username=? and pwd=?", new BeanHandler<Admin>(Admin.class),username,pwd);
} catch (SQLException e) {
throw new RuntimeException(e);//抛出运行异常
}
}
@Override
public Admin queryByUsername(String username) {
try {
return runner.query("select * from admin where username=? ", new BeanHandler<Admin>(Admin.class),username);
} catch (SQLException e) {
throw new RuntimeException(e);//抛出运行异常
}
}
public int updateAdmin(Admin admin) {//更改管理员信息
try {//执行更改
runner.update("update admin set username=?,pwd=?,nickname=? where id=?",
admin.getUsername(),admin.getPwd(),admin.getNickname(),admin.getId());
} catch (SQLException e) {
throw new RuntimeException(e);//抛出运行异常
}
return 1;
}
@Override
public Admin queryAdminByid(Integer id) {
try {//返回查询的信息
return runner.query("select * from admin where id=?",new BeanHandler<Admin>(Admin.class),id);
} catch (SQLException e) {
throw new RuntimeException(e);//抛出运行异常
}
}
后面还有 14 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。