Пример #1
0
  /**
   * Verifica se sessao esta ativa
   *
   * @numero : 01
   * @author : Felipe Francesconi Riserio
   * @parametro : objeto usuario
   * @return : True or false
   * @throws : SQLException
   */
  public boolean sessaoIsOk(Usuario usu) throws SQLException {
    String sql = "EXEC DB_PORTAL.DBO.SESSAO ?,?";

    PreparedStatement stmt = this.connection.prepareStatement(sql);

    if (usu.getAssinatura() != null && usu.getUsuario() != null) {
      stmt.setString(1, usu.getUsuario());
      stmt.setInt(2, Integer.parseInt(usu.getAssinatura()));
    } else return false;

    ResultSet rs = stmt.executeQuery();

    try {
      while (rs.next()) {
        if (rs.getInt("retorno") == 0) return true;
        else return false;
      }
    } catch (Exception e) {
      System.out.println("01 " + classe + " " + e.toString());
      e.printStackTrace();
      return false;
    } finally {
      stmt.close();
      rs.close();
    }
    return false;
  }
Пример #2
0
  public boolean isAdministrador(Usuario usuario) throws SQLException {

    String sql = "EXEC PRTL_SP_ACESSO_POR_USUARIO ?,?";

    PreparedStatement stmt = this.connection.prepareStatement(sql);
    stmt.setString(1, usuario.getUsuario());
    stmt.setInt(2, 78);
    ResultSet rs = stmt.executeQuery();

    try {
      while (rs.next()) {
        if (rs.getInt("id_permissao") == 5) {
          return true;
        } else {
          return false;
        }
      }
    } catch (Exception e) {
      System.out.println("02 " + classe + " " + e.toString());
      e.printStackTrace();
    } finally {
      stmt.close();
      rs.close();
    }

    return false;
  }