package com.java.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; import com.java.model.Info; import com.java.util.StringUtil; public class InfoDao { public Info infoone(Connection con,String id)throws Exception{ String sql = "select * from info where id = ?"; PreparedStatement pstmt = con.prepareStatement(sql); pstmt.setString(1,id); Info info = new Info(); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { info.setId(rs.getInt("id")); info.setName(rs.getString("name")); info.setSex(rs.getString("sex")); info.setAge(rs.getInt("age")); info.setJoin_time(rs.getInt("join_time")); info.setCard(rs.getInt("card")); } return info; } public List<Info> infoList(Connection con,Info info)throws Exception{ String sql = "select * from info"; PreparedStatement pstmt = con.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); List<Info> infoList = new ArrayList<Info>(); while (rs.next()) { Info info1 = new Info(); info1.setId(rs.getInt("id")); info1.setName(rs.getString("name")); info1.setSex(rs.getString("sex")); info1.setAge(rs.getInt("age")); info1.setJoin_time(rs.getInt("join_time")); info1.setCard(rs.getInt("card")); infoList.add(info1); } return infoList; } public int infoDelete(Connection con,String delIds)throws Exception{ String sql="delete from info where id in("+delIds+")"; PreparedStatement pstmt=con.prepareStatement(sql); return pstmt.executeUpdate(); } public int infoAdd(Connection con,Info info)throws Exception{ String sql="insert into info values(null,?,?,?,?,?)"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1,info.getName()); pstmt.setString(2,info.getSex()); pstmt.setInt(3,info.getAge()); pstmt.setInt(4,info.getJoin_time()); pstmt.setInt(5,info.getCard()); return pstmt.executeUpdate(); } public int infoModify(Connection con,Info info)throws Exception{ String sql="update info set card=?,name=?,sex=?,age=?,join_time=? where id=?"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setInt(1,info.getCard()); pstmt.setString(2,info.getName()); pstmt.setString(3,info.getSex()); pstmt.setInt(4,info.getAge()); pstmt.setInt(5,info.getJoin_time()); pstmt.setInt(6, info.getId()); return pstmt.executeUpdate(); } }


酷少小新 LV2
6月8日
新哥新奇士橙 LV4
1月26日
yongle LV1
2024年12月31日
微信网友_7313889549307904
2024年12月27日
暂无贡献等级
1453666970
2024年12月27日
暂无贡献等级
ma406805131 LV19
2024年12月19日
xiaoaitx LV8
2024年11月18日
张泽帅 LV6
2024年10月18日
赵鑫cdsaljkdfsa LV11
2024年7月2日
琐事消极
2024年7月1日
暂无贡献等级