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()); } }
最近下载更多
wanglinddad LV55
3月13日
hyt123456 LV2
2月9日
全栈小陈 LV4
1月21日
微信网友_6829521472425984 LV5
1月20日
kongmaowang LV1
1月5日
yangyangyangyangzzzz LV1
1月3日
pangzhihui LV13
2023年12月30日
asddwh LV12
2023年12月29日
无敌最俊朗啊 LV2
2023年12月29日
moranying LV1
2023年12月28日
最近浏览更多
暂无贡献等级
Dominick LV14
4月28日
justinleo LV1
4月14日
twedss
3月31日
暂无贡献等级
钝感力 LV1
3月24日
sunlzh888888 LV28
3月16日
wanglinddad LV55
3月13日
quartz LV7
3月13日
晴曛 LV6
3月10日
潘潘123456 LV2
3月2日