You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
teeth/code/ReportDaoImpl.java

59 lines
1.5 KiB

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;
}
}
}