package dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import domain.User2; import util.ConnectionUtil; public class User2Dao { public boolean addUser(User2 user){ String sql = "insert into user4(username,password) values(?,?)"; Object[] params = { user.getUsername(), user.getPassword(), }; return ConnectionUtil.executeUpdate(sql, params); } public User2 queryUser(User2 user){ String sql = "select * from user4 where username = ?"; Connection conn = ConnectionUtil.getConection(); PreparedStatement ps = null; try { ps = conn.prepareStatement(sql); ps.setObject(1, user.getUsername()); ResultSet rs = ps.executeQuery(); User2 u = null; if(rs.next()){ int id = rs.getInt("id"); String username = rs.getString("username"); String password = rs.getString("password"); u = new User2(username, password); } if(u.getPassword().equals(user.getPassword())){ return u; }else{ return null; } } catch (SQLException e) { e.printStackTrace(); return null; } } }
最近下载更多
微信网友_6906962132258816 LV6
3月16日
asddwh LV12
1月1日
时光凉薄 LV2
2023年12月27日
黄乐大哥好帅 LV1
2023年12月5日
2386672094 LV1
2023年11月15日
321170193 LV6
2023年11月12日
哈哈ha zhh LV2
2023年11月7日
微信网友_6532388217475072 LV1
2023年6月24日
张真狗 LV9
2023年5月22日
whn515 LV1
2023年4月21日
最近浏览更多
tartaglia LV2
4月16日
微信网友_6906962132258816 LV6
3月16日
实话大王
1月24日
暂无贡献等级
xiquyiyuan LV10
1月12日
陈小灏 LV14
1月11日
无敌最俊朗啊 LV2
2023年12月29日
时光凉薄 LV2
2023年12月27日
火星族
2023年12月26日
暂无贡献等级
hanzhuohong LV1
2023年12月25日
yyidaaa LV1
2023年12月25日