parent
5da515c209
commit
ba75e41c23
@ -0,0 +1,98 @@
|
||||
package com.dao;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.sql.*;
|
||||
import com.domain.Authority;
|
||||
|
||||
public class AuthorityDaoImpl implements AuthorityDao {
|
||||
|
||||
// 随机检索学生方法
|
||||
// public PostCheck findDyid(int Dyid) throws DaoException{
|
||||
// String sql="SELECT Dyid,Uid,Uname,Rtime,Content"+"FROM Dynamic WHERE id=?";
|
||||
// PostCheck postcheck = new PostCheck();
|
||||
// try(
|
||||
// Connection conn=getConnection();
|
||||
// PreparedStatement pstmt=conn.prepareStatement(sql)){
|
||||
// pstmt.setInt(1, Dyid);
|
||||
// try(ResultSet rst=pstmt.executeQuery()){
|
||||
// if(rst.next()) {
|
||||
// postcheck.setDyid(rst.getInt("Dyid"));
|
||||
// postcheck.setUid(rst.getString("Uid"));
|
||||
// postcheck.setUname(rst.getString("Uname"));
|
||||
// postcheck.setRtime(rst.getDate("Rtime"));
|
||||
// postcheck.setContent(rst.getString("Content"));
|
||||
// }
|
||||
// }
|
||||
// }catch(SQLException se) {
|
||||
// return null;
|
||||
// }
|
||||
// return postcheck;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public List<Authority> listAuthority() throws SQLException {
|
||||
// TODO Auto-generated method stub
|
||||
Authority Authority = new Authority();
|
||||
|
||||
Connection conn = getConnection();
|
||||
List<Authority> list = new ArrayList<Authority>();
|
||||
String sql = "SELECT * FROM Authority";
|
||||
try (
|
||||
PreparedStatement pstmt = conn.prepareStatement(sql);
|
||||
ResultSet rs = pstmt.executeQuery()){
|
||||
System.out.println(rs+"test1");
|
||||
while(rs.next()){
|
||||
// int Dyid = rs.getInt("Dyid");
|
||||
// String Uid = rs.getString(2);
|
||||
// String Uname = rs.getString(3);
|
||||
// Date Rtime = rs.getDate(4);
|
||||
// String Content = rs.getString(5);
|
||||
// PostCheck s = new PostCheck();
|
||||
// s.setDyid(Dyid);
|
||||
// s.setUid(Uid);
|
||||
// s.setUname(Uname);
|
||||
// s.setRtime(Rtime);
|
||||
// s.setContent(Content);
|
||||
// System.out.println(list+"test2");//
|
||||
// list.add(s);
|
||||
Authority.setCid(rs.getInt("Cid"));
|
||||
Authority.setUid(rs.getString("Uid"));
|
||||
Authority.setIid(rs.getString("Iid"));
|
||||
Authority.setProfession(rs.getString("Profession"));
|
||||
Authority.setCompany(rs.getString("Company"));
|
||||
Authority.setPicture(rs.getBytes("Picture"));
|
||||
list.add(Authority);
|
||||
}
|
||||
System.out.println(list+"test2");
|
||||
return list;
|
||||
|
||||
}catch(SQLException e){
|
||||
System.out.println(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
// 删除动态
|
||||
public int removeAuthority(int Cid) throws SQLException {
|
||||
// TODO Auto-generated method stub
|
||||
Connection conn = getConnection();
|
||||
String sql = "DELETE FROM Authority WHERE Cid=?";
|
||||
try {
|
||||
|
||||
PreparedStatement pstmt = conn.prepareStatement(sql);
|
||||
pstmt.setInt(1, Cid);
|
||||
return pstmt.executeUpdate();
|
||||
}catch(SQLException sqle){
|
||||
System.out.println(sqle);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in new issue