package dao;
import model.User;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class UserDao {
public User login(Connection con, User user) throws Exception {
User resultUser = null;
String sql = "select*from user where userName=? and password=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
pstmt.setString(2, user.getPassword());
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
resultUser = new User();
resultUser.setId(rs.getInt("id"));
resultUser.setUserName(rs.getString("userName"));
resultUser.setPassword(rs.getString("password"));
}
return resultUser;
}
//用户注册
public int addUser(Connection con, User user) throws Exception {
String sql = "insert into user values(null,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
pstmt.setString(2, user.getPassword());
return pstmt.executeUpdate();
}
}
最近下载更多
wahukkk LV1
6月23日
随便取个名字_哈哈 LV27
6月23日
pxqtsht LV16
2月21日
120_wu LV4
2024年12月3日
srl2881552 LV10
2024年11月25日
wanglinddad LV55
2024年3月26日
weilaizhisheng LV21
2023年11月30日
卢本伟不开挂 LV4
2023年9月3日
微信网友_6000801142263808 LV3
2023年6月18日
wipeout LV1
2023年6月17日
最近浏览更多
随便取个名字_哈哈 LV27
6月23日
wahukkk LV1
6月22日
没有啊很开心啊 LV4
3月10日
docnnxxy688
3月1日
暂无贡献等级
pxqtsht LV16
2月21日
短巷拥猫 LV12
2024年12月23日
571818771 LV3
2024年12月17日
120_wu LV4
2024年12月3日
srl2881552 LV10
2024年11月25日
summer0613
2024年11月19日
暂无贡献等级

