Esempio n. 1
0
  public List<User> getUserList() {

    List<User> userList = new ArrayList();
    SSRS ssrs = es.execSQL("SELECT ID, USERNAME, PASSWORD, MENUJSON FROM SYJK_CCS_USER ");
    if (ssrs.MaxRow > 0) {
      for (int i = 0; i < ssrs.MaxRow; i++) {
        User user = new User();
        user.setId(Integer.parseInt(ssrs.GetText(i + 1, 1)));
        user.setUserName(ssrs.GetText(i + 1, 2));
        user.setPassWord(ssrs.GetText(i + 1, 3));
        user.setMenujson(ssrs.GetText(i + 1, 4));
        userList.add(user);
      }
    }
    return userList;
  }
Esempio n. 2
0
  // 验证登录用户是否存在
  public User ChkUser(String userName, String passWord) {

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    Connection conn = null;
    try {
      conn = DBConnPool.getConnection();
    } catch (NoFreeConnectionException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    User user = null;
    String sql = "select t.*, t.rowid from syjk_ccs_user t where t.username=? and t.password=?";

    try {
      pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, userName);
      pstmt.setString(2, passWord);
      rs = pstmt.executeQuery();
      if (rs.next()) {
        user = new User();
        user.setUserName(rs.getString("userName"));
        user.setPassWord(rs.getString("passWord"));
        user.setMenujson(rs.getString("menujson"));
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        if (rs != null) {
          rs.close();
        }
        if (pstmt != null) {
          pstmt.close();
        }
        ConnectDBBean.closeConnection(
            ReadWriteDBPool.readPool, conn); //  因关闭方式有问题  需要原来的关闭方式进行连接的关闭  mili 2015-3-20 16:34:57
        //				if(conn != null){
        //					conn.close();
        //				}
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return user;
  }