public void creat(Reader rd) {
   Connection cn = null;
   PreparedStatement ps = null;
   try {
     cn = JDBCTools.getConnection();
     String spl =
         "insert into reader(r_id,r_password,r_name,r_age,r_typed,r_sex,r_dept,r_phone,r_address,r_photo)values(?,?,?,?,?,?,?,?,?,?)";
     ps = cn.prepareStatement(spl);
     ps.setString(1, rd.getReaderid());
     ps.setString(2, rd.getPassword());
     ps.setString(3, rd.getName());
     ps.setInt(4, rd.getAge());
     ps.setInt(5, rd.getTyped());
     ps.setString(6, rd.getSex());
     ps.setString(7, rd.getDept());
     ps.setString(8, rd.getPhone());
     ps.setString(9, rd.getAddress());
     ps.setString(10, rd.getPhoto());
     ps.executeUpdate();
   } catch (SQLException e) {
     throw new DaoException();
   } finally {
     JDBCTools.free(ps, cn);
   }
 }
  public boolean readLogin(Reader rd) {
    Connection cn = null;
    Statement ps = null;
    ResultSet rs = null;
    try {
      cn = JDBCTools.getConnection();
      ps = cn.createStatement();
      rs = ps.executeQuery("select *from reader");
      while (rs.next()) {
        boolean w =
            rd.getReaderid().equals(rs.getString(1)) && rd.getPassword().equals(rs.getString(2));
        if (w) {
          return true;
        }
      }

    } catch (SQLException e) {
      throw new DaoException();
    } finally {
      try {
        if (cn != null) cn.close();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } finally {
        try {
          if (ps != null) ps.close();
        } catch (SQLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } finally {
          try {
            if (rs != null) rs.close();
          } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    }

    return false;
  }
  public void delete(Reader rd) {
    Connection cn = null;
    PreparedStatement ps = null;
    try {
      cn = JDBCTools.getConnection();
      String spl = "delete from reader where r_id=?";
      ps = cn.prepareStatement(spl);
      ps.setString(1, rd.getReaderid());
      ps.executeUpdate();
    } catch (SQLException e) {
      throw new DaoException();
    } finally {

      JDBCTools.free(ps, cn);
    }
  }
  public Reader read(String n) {
    Connection cn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    Reader rd = null;

    try {
      cn = JDBCTools.getConnection();
      String spl =
          "select r_name,r_age,r_typed,r_sex,r_dept,r_phone,r_address,r_photo from reader where r_id=?";
      ps = cn.prepareStatement(spl);
      ps.setString(1, n);
      rs = ps.executeQuery();
      while (rs.next()) {
        rd = new Reader();
        rd.setName(rs.getString(1));
        rd.setAge(rs.getInt(2));
        rd.setTyped(rs.getInt(3));
        rd.setSex(rs.getString(4));
        rd.setDept(rs.getString(5));
        rd.setPhone(rs.getString(6));
        rd.setAddress(rs.getString(7));
        rd.setPhoto(rs.getString(8));
      }

    } catch (SQLException e) {
      throw new DaoException(e.getMessage(), e);
    }

    try {
      rs.close();
    } catch (SQLException e) {
      throw new DaoException();
    } finally {
      JDBCTools.free(ps, cn);
    }

    return rd;
  }