package com.mitsui.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import com.mitsui.domain.File; import com.mitsui.util.ConnectionUtil; public class FileDao { public boolean addFile(File file){ String sql = "insert into stafffile(file_id,p_id,file_name,file_abstract,reward_note,experience) values(?,?,?,?,?,?)"; Object[] params = { file.getFile_id(), file.getP_id(), file.getFile_name(), file.getFile_abstract(), file.getReward_note(), file.getExperience(), }; return ConnectionUtil.executeUpdate(sql, params); } public List<File> queryAllFile(){ String sql = "select * from stafffile"; Connection conn = ConnectionUtil.getConection(); PreparedStatement ps = null; try { ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); File u = null; List<File> files = new ArrayList<File>(); while(rs.next()){ int file_id = rs.getInt("file_id"); int p_id = rs.getInt("p_id"); String file_name = rs.getString("file_name"); String file_abstract = rs.getString("file_abstract"); String reward_note = rs.getString("reward_note"); String experience = rs.getString("experience"); u = new File(file_id, p_id, file_name, file_abstract, reward_note, experience); files.add(u); } return files; } catch (SQLException e) { e.printStackTrace(); return null; } } public boolean deleteFile(Integer file_id){ String sql = "delete from stafffile where file_id = ?"; Object[] params = { file_id }; return ConnectionUtil.executeUpdate(sql, params); } public File queryFile(Integer file_id){ String sql = "select * from stafffile where file_id = ?"; Connection conn = ConnectionUtil.getConection(); PreparedStatement ps = null; try { ps = conn.prepareStatement(sql); ps.setInt(1, file_id); ResultSet rs = ps.executeQuery(); File u = null; if(rs.next()){ int p_id = rs.getInt("p_id"); String file_name = rs.getString("file_name"); String file_abstract = rs.getString("file_abstract"); String reward_note = rs.getString("reward_note"); String experience = rs.getString("experience"); u = new File(file_id, p_id, file_name, file_abstract, reward_note, experience); } return u; } catch (SQLException e) { e.printStackTrace(); return null; } } public boolean updateFile(File file){ String sql = "update stafffile set p_id = ?,file_name = ?,file_abstract = ?,reward_note = ?,experience = ?where file_id = ?"; Object[] params = { file.getP_id(), file.getFile_name(), file.getFile_abstract(), file.getReward_note(), file.getExperience(), file.getFile_id(), }; return ConnectionUtil.executeUpdate(sql, params); } public static List<File> queryOneFile(int id) { String sql = "select * from stafffile where P_id = "+ id +""; Connection conn = ConnectionUtil.getConection(); PreparedStatement ps = null; try { ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); File u = null; List<File> files = new ArrayList<File>(); while(rs.next()){ int file_id = rs.getInt("file_id"); int p_id = rs.getInt("p_id"); String file_name = rs.getString("file_name"); String file_abstract = rs.getString("file_abstract"); String reward_note = rs.getString("reward_note"); String experience = rs.getString("experience"); u = new File(file_id, p_id, file_name, file_abstract, reward_note, experience); files.add(u); } return files; } catch (SQLException e) { e.printStackTrace(); return null; } } }

yuanshun LV7
2023年12月14日
微醺酸梅汤 LV2
2023年9月27日
husiyu LV3
2023年9月25日
duoer12 LV5
2022年12月30日
wangxiaolaugh LV2
2022年12月27日
194897762 LV4
2022年12月26日
485415187 LV6
2022年11月20日
aduahfue LV4
2022年10月25日
13940562934 LV22
2022年7月2日
donglixue LV6
2022年6月28日

微信网友_7338401665241088
1月13日
暂无贡献等级
自选菜
2024年11月21日
暂无贡献等级
张泽帅 LV6
2024年10月18日
krispeng LV14
2024年8月12日
liuaaa
2024年6月24日
暂无贡献等级
微信网友_7041475584184320
2024年6月17日
暂无贡献等级
123456cjj LV1
2024年6月2日
微信网友_7009341063450624
2024年6月1日
暂无贡献等级
微信网友_6906962132258816 LV7
2024年5月15日
爱丽淇 LV5
2024年3月13日