package com.wy.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; import com.wy.form.FriendForm; import com.wy.tool.JDBConnection; public class FriendDao { private JDBConnection connection = null; public FriendDao() { connection = new JDBConnection(); } // 修改朋友 public boolean updateFriend(FriendForm form) { boolean flag = false; String sql = "update tb_friend set name='" + form.getName() + "',QQNumber='" + form.getQQNumber() + "',description='" + form.getDescription() + "' where id='" + form.getId() + "'"; if (connection.executeUpdate(sql)) { flag = true; } return flag; } // 添加朋友 public boolean addFriend(FriendForm form) { boolean flag = false; String sql = "insert into tb_friend values ("+(int)Math.random()*99999999+",'" + form.getName() + "','" + form.getQQNumber() + "','" + form.getDescription() + "')"; if (connection.executeUpdate(sql)) { flag = true; } return flag; } // 删除朋友 public boolean deleteFriend(Integer id) { boolean flag = false; String sql = "delete from tb_friend where id='" + id + "'"; if (connection.executeUpdate(sql)) { flag = true; } return flag; } // 查询所有朋友 public List queryFriend() { List list = new ArrayList(); FriendForm form = null; String sql = "select * from tb_friend"; ResultSet rs = connection.executeQuery(sql); try { while (rs.next()) { form = new FriendForm(); form.setId(Integer.valueOf(rs.getString(1))); form.setName(rs.getString(2)); form.setQQNumber(rs.getString(3)); form.setDescription(rs.getString(4)); list.add(form); } } catch (SQLException e) { e.printStackTrace(); } return list; } // 单独朋友信息查询 public FriendForm queryFriendForm(String id) { FriendForm form = null; String sql = "select * from tb_friend where id='" + id + "'"; ResultSet rs = connection.executeQuery(sql); try { while (rs.next()) { form = new FriendForm(); form.setId(Integer.valueOf(rs.getString(1))); form.setName(rs.getString(2)); form.setQQNumber(rs.getString(3)); form.setDescription(rs.getString(4)); } } catch (SQLException e) { e.printStackTrace(); } return form; } }
最近下载更多
sz1111111 LV2
3月26日
寒江雪2017 LV9
1月23日
李朝磊 LV18
1月6日
pangzhihui LV12
2023年12月27日
wanglongfei2 LV2
2023年6月15日
13133117021 LV4
2023年5月31日
ewan007 LV29
2023年3月13日
你们的代码都是我的了 LV16
2022年12月5日
gnnhka LV10
2022年11月8日
SQ2930501923 LV14
2022年10月10日
最近浏览更多
sz1111111 LV2
3月26日
寒江雪2017 LV9
1月23日
duoduo1234 LV2
1月15日
taoshen95 LV14
1月11日
wttttts LV2
1月1日
hxy19991216 LV4
2023年12月30日
asddwh LV12
2023年12月29日
pangzhihui LV12
2023年12月27日
李朝磊 LV18
2023年12月21日
颜菜菜 LV2
2023年12月19日