parent
f13c6e943a
commit
4facf8ed39
@ -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<Report> listReport() throws SQLException {
|
||||
// TODO Auto-generated method stub
|
||||
Report Report = new Report();
|
||||
Connection conn = getConnection();
|
||||
List<Report> list = new ArrayList<Report>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue