Ejemplo n.º 1
0
  /**
   * 说明:获取指定系统指定部门标识的部门对象
   *
   * @param con 数据库连接对象
   * @param sysid 系统标识
   * @param depid 部门标识
   * @return
   * @throws LawyerException
   */
  public Department queryDepartment(Connection con, String sysid, String depid)
      throws LawyerException {
    String sql =
        "SELECT ID,NAME,STATUS,SDATE,EDATE,REMARKS,PRINCIPAl,SYSID FROM "
            + DEPTABLE
            + " WHERE SYSID='"
            + sysid
            + "' AND ID='"
            + depid
            + "'";
    Statement statment = null;
    ResultSet result = null;
    try {
      statment = con.createStatement();
      result = statment.executeQuery(sql);
      Department department = null;
      while (result.next()) {
        department = new Department(result.getString("SYSID"), result.getString("ID"));
        department.setName(result.getString("NAME"));
        department.setStatus(result.getString("STATUS"));
        department.setSdate(result.getDate("SDATE"));
        department.setEdate(result.getDate("EDATE"));
        department.setPrincipal(result.getString("PRINCIPAl"));
        department.setRemarks(result.getString("REMARKS"));
        break;
      }
      return department;

    } catch (SQLException e) {
      throw new LawyerException("Query Department is error! " + e.getMessage());
    } finally {
      try {
        result.close();
        statment.close();
      } catch (SQLException e) {
      }
      result = null;
      statment = null;
    }
  }