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()); } }

1273251505 LV1
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日
hyt123456 LV3
2024年2月9日

武诗惠
6月12日
暂无贡献等级
renjunyou LV10
6月2日
李玟龙 LV2
5月21日
yangchengshuai LV15
3月7日
微信网友_7289626841501696 LV4
3月6日
docnnxxy688
3月1日
暂无贡献等级
1273251505 LV1
1月5日
经典拿铁
2024年12月29日
暂无贡献等级
3375276400
2024年12月24日
暂无贡献等级
ma406805131 LV19
2024年12月18日