From 4facf8ed39b877e821fa8d78076c303934e76a3f Mon Sep 17 00:00:00 2001 From: pfu2aoslz <2269185321@qq.com> Date: Thu, 6 Jan 2022 23:17:29 +0800 Subject: [PATCH] ADD file via upload --- code/ReportDaoImpl.java | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 code/ReportDaoImpl.java diff --git a/code/ReportDaoImpl.java b/code/ReportDaoImpl.java new file mode 100644 index 0000000..7c81c63 --- /dev/null +++ b/code/ReportDaoImpl.java @@ -0,0 +1,58 @@ +package com.dao; +import java.util.*; + + +import java.util.Date; +import java.sql.*; + +import com.domain.Article; +import com.domain.Report; + +public class ReportDaoImpl implements ReportDao { + + @Override + public List listReport() throws SQLException { + // TODO Auto-generated method stub + Report Report = new Report(); + Connection conn = getConnection(); + List list = new ArrayList(); + String sql = "SELECT * FROM Report"; + try( + PreparedStatement pstmt = conn.prepareStatement(sql); + ResultSet rs = pstmt.executeQuery()){ + while(rs.next()){ + Report.setRid(rs.getInt("Rid")); + Report.setUid(rs.getString("Uid")); + Report.setRdate(rs.getDate("Rdate")); + Report.setResult(rs.getString("Result")); + Report.setCompany(rs.getString("Company")); + Report.setRpicture(rs.getBytes("Rpicture")); + list.add(Report); + } + return list; + }catch(SQLException e){ + System.out.println(e); + return null; + } + + } + + @Override + public int removeReport(int Rid) throws SQLException { + // TODO Auto-generated method stub + Connection conn = getConnection(); + String sql = "DELETE FROM Report WHERE Rid=?"; + try{ + PreparedStatement pstmt = conn.prepareStatement(sql); + pstmt.setInt(1, Rid); + return pstmt.executeUpdate(); + }catch(SQLException sqle){ + System.out.print(sqle); + return 0; + } + } + + + +} +