package cn.itcast.dao.impl;
import cn.itcast.dao.UserDao;
import cn.itcast.domain.Student;
import cn.itcast.domain.User;
import cn.itcast.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
public class UserDaoImpl implements UserDao {
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
@Override
public User findUserByUsernameAndPassword(String username, String password) {
try {
String sql = "select * from user where username = ? and password = ?";
User student = template.queryForObject(sql, new BeanPropertyRowMapper<User>(User.class), username, password);
return student;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@Override
public void add(User user) {
//1.定义sql
String sql = "insert into user values(null,?,?)";
//2.执行sql
template.update(sql, user.getUsername(),user.getPassword());
}
}
最近下载更多
1271247100 LV9
2025年11月22日
1273251505 LV1
2025年1月5日
ma406805131 LV19
2024年12月19日
TTThai LV1
2024年12月17日
xiaoaitx LV8
2024年11月19日
微信网友_6520355827929088 LV2
2024年11月18日
krispeng LV15
2024年9月10日
Darchry LV2
2024年6月29日
taoshen95 LV16
2024年6月25日
wanglinddad LV55
2024年3月13日
最近浏览更多
nfsuhfksd
2025年12月23日
暂无贡献等级
1271247100 LV9
2025年11月21日
武诗惠
2025年6月12日
暂无贡献等级
renjunyou LV10
2025年6月2日
李玟龙 LV2
2025年5月21日
yangchengshuai LV16
2025年3月7日
微信网友_7289626841501696 LV4
2025年3月6日
docnnxxy688
2025年3月1日
暂无贡献等级
1273251505 LV1
2025年1月5日
经典拿铁
2024年12月29日
暂无贡献等级

