예제 #1
0
  public boolean getIsShowRec(String areaID, String userName) throws BusinessException {
    boolean returnBln = false;

    Connection myConn = DAOFactory.getInstance().getConnection();
    Statement statement = null;
    try {
      statement = myConn.createStatement();
      String tempSql =
          "select IS_DISPLAY_REC from AS_DESKTOP "
              + "where AREA_ID='"
              + areaID
              + "' and USER_ID='"
              + userName
              + "'";
      ResultSet rs = statement.executeQuery(tempSql);
      if (rs.next()) {
        String tempStr = rs.getString("IS_DISPLAY_REC");
        returnBln = tempStr == null ? false : tempStr.equalsIgnoreCase("y");
      } else {
        throw new BusinessException("数据库中没有,区域号:" + areaID + "   用户名:" + userName + " 的信息!");
      }

    } catch (SQLException ex) {
      throw new RuntimeException("DeskTopBean类的areaNametoID方法:在桌面的区域中" + "加入部件时,SQL语句执行错误!");
    } finally {
      DBHelper.closeConnection(myConn, statement, null);
    }
    return returnBln;
  }
예제 #2
0
  public String getie5menu() {
    StringBuffer sb = new StringBuffer();

    sb.append(
        "<div id=\"ie5menu\" class=\"rightKeyMenu\" onMouseover=\"highlightie5()\" onMouseout=\"lowlightie5()\">");
    sb.append(
        "<div id=\"ie5new\" class=\"menuitems\" onclick=\"gotoNewPage()\">&nbsp;&nbsp;新窗口打开</div>");
    sb.append("      <hr>");
    // sb.append(" <div id=\"ie5add\" class=\"menuitems\"
    // onclick=\"addToFavorite()\">&nbsp;&nbsp;加入收藏夹</div>");
    // sb.append("<div id=\"ie5del\" class=\"menuitems\"
    // onclick=\"delFromFavorite()\">&nbsp;&nbsp;从收藏夹删除</div>");
    Connection conn = null;
    Statement statement = null;
    ResultSet rs = null;
    int i = 0;
    try {
      StringBuffer sql = new StringBuffer();
      sql.append("select DISTINCT AREA_ID,AREA_NAME,AREA_INDEX from AS_DESKTOP where USER_ID= '");
      sql.append(this.userID);
      sql.append("'");
      sql.append(" order by AREA_INDEX");
      conn = DAOFactory.getInstance().getConnection();

      statement = conn.createStatement();
      rs = statement.executeQuery(sql.toString());

      while (rs.next()) {
        sb.append(
            "         <div id=\"ie5add"
                + i
                + "\" class=\"menuitems\" onclick=\"addToA()\">&nbsp;&nbsp;");
        sb.append("加入");
        sb.append(rs.getString("AREA_NAME"));
        sb.append("</div>");
        i++;
        if (i == 4) {
          break;
        }
      }
    } catch (SQLException ex) {
      throw new RuntimeException("DeskTopBean类的getIe5menu方法:" + "SQL语句执行错误!" + ex.toString());
    } finally {
      DBHelper.closeConnection(conn, statement, rs);
    }
    sb.append("  </div>");

    return sb.toString();
  }
예제 #3
0
 public static String getDBServerURL() {
   Connection conn = null;
   try {
     conn = DAOFactory.getInstance().getConnection();
     if (conn != null) {
       DatabaseMetaData meta = conn.getMetaData();
       return (meta.getURL() + ":" + meta.getUserName()).toUpperCase();
     }
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     DBHelper.closeConnection(conn);
   }
   return "";
 }
예제 #4
0
  /** 修改口令 */
  public boolean changePasswd() {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    java.util.Date currDate = new java.util.Date();
    String nowtime = formatter.format(currDate);

    String sqlStr = null;
    PreparedStatement pst = null;

    if (userId != null && !userId.equals("")) {
      Connection conn = DAOFactory.getInstance().getConnection();
      try {
        boolean autoCommit = conn.getAutoCommit();
        conn.setAutoCommit(false);

        sqlStr = " update AS_USER set PASSWD = ? ,MODI_TIME = ? where USER_ID = ? ";
        pst = conn.prepareStatement(sqlStr);

        int i = 1;
        pst.setString(i++, newPassword);
        pst.setString(i++, nowtime);
        pst.setString(i++, userId);

        int infectedRows = pst.executeUpdate();
        if (infectedRows > 1) {
          conn.rollback();
          conn.setAutoCommit(autoCommit);
          log.error(sqlStr);
          // System.out.println("非法修改口令,请系统管理员检查系统日志(rolling.log)。");
          return false;
        }

        conn.commit();
        conn.setAutoCommit(autoCommit);

        return true;
      } catch (SQLException se) {
        throw new RuntimeException("类SavePasswordAction方法changePasswd()出错:" + se.getMessage());
      } finally {
        DBHelper.closeConnection(conn, pst, null);
      }
    }
    return false;
  }
예제 #5
0
  /**
   * 验证口令
   *
   * @return flag boolean变量
   */
  public boolean checkPasswd() {
    boolean flag = false;
    String sqlStr = null;
    ResultSet rs = null;
    PreparedStatement pst = null;
    sqlStr = "select PASSWD from AS_USER where USER_ID = ?";

    if (userId != null && oldPassword != null) {
      Connection conn = DAOFactory.getInstance().getConnection();
      try {
        pst = conn.prepareStatement(sqlStr);
        int i = 1;
        pst.setString(i++, userId);

        rs = pst.executeQuery();
        if (rs.next()) {
          String p = rs.getString(1);
          if (p != null && p.equals("")) {
            p = null;
          }
          if (oldPassword != null && oldPassword.equals("")) {
            oldPassword = null;
          }
          if (p == null) {
            if (oldPassword == null) {
              flag = true;
            }
          } else {
            if (oldPassword != null && p.equals(oldPassword)) {
              flag = true;
            }
          }
        }
      } catch (SQLException se) {
        throw new RuntimeException("类SavPasswordAction方法checkPasswd()出错:" + se.getMessage());
      } finally {
        DBHelper.closeConnection(conn, pst, rs);
      }
    }
    return flag;
  }
예제 #6
0
  public void init() {

    Connection conn = null;
    Statement statement = null;
    ResultSet rs = null;
    int i = 0;
    StringBuffer sql = new StringBuffer();
    StringBuffer insertSql = new StringBuffer();
    try {
      DesktopArea desktopArea;
      sql.append("select DISTINCT AREA_ID, AREA_INDEX, DISPLAY_AMOUNT, ");
      sql.append("IS_DISPLAY_REC from AS_DESKTOP where USER_ID='");
      sql.append(this.getUserID());
      sql.append("' order by AREA_INDEX ");
      conn = DAOFactory.getInstance().getConnection();

      statement = conn.createStatement();
      rs = statement.executeQuery(sql.toString());
      while (rs.next()) {
        boolean tempBln = rs.getString("IS_DISPLAY_REC").equalsIgnoreCase("Y");
        desktopArea =
            DesktopArea.getInstanceFromDB(rs.getString("AREA_ID"), this.request, this.getUserID());
        desktopArea.setDisplayAmount(rs.getInt("DISPLAY_AMOUNT"));
        desktopArea.setIsDisplayRec(tempBln);
        this.deskTopAreas.put(new Integer(i + 1), desktopArea);
        i++;
        if (i == 4) {
          break;
        }
      }
      if (i == 0) {
        insertSql.append(
            "insert into AS_DESKTOP (AREA_ID, USER_ID,AREA_NAME,  AREA_INDEX, AREA_IMG) ");
        insertSql.append("SELECT AREA_ID,'");
        insertSql.append(this.getUserID());
        insertSql.append("', AREA_NAME, AREA_INDEX, AREA_IMG ");
        insertSql.append("FROM AS_DESKTOP WHERE USER_ID='sa'");
        if (statement.executeUpdate(insertSql.toString()) > 0) {
          rs = statement.executeQuery(sql.toString());
          while (rs.next()) {
            desktopArea =
                DesktopArea.getInstanceFromDB(
                    rs.getString("AREA_ID"), this.request, this.getUserID());
            this.deskTopAreas.put(new Integer(i + 1), desktopArea);
            i++;
            if (i == 4) {
              break;
            }
          }
        }
      }
    } catch (SQLException ex) {
      if (i == 0) {
        System.out.println(insertSql);
      } else {
        System.out.println(sql);
      }
      ex.printStackTrace();
      log.error(ex);
      throw new RuntimeException("DeskTopBean类的init方法:" + "SQL语句执行错误!", ex);
    } catch (BusinessException ex) {
      log.error(ex);
      throw new RuntimeException("DeskTopBean类的init方法:" + "出现业务异常!", ex);
    } finally {
      DBHelper.closeConnection(conn, statement, rs);
    }
  }