Example #1
0
  public Boolean Alterar(DtoHistorico dtoHistorico) throws Exception {

    try {
      if (!VerifiqueConexao()) return false;

      comandoSql = "UPDATE HISTORICO SET DATA=?, CODIGOUSUARIO=?, CODIGOMUSICA=? WHERE CODIGO = ?";
      pst = (PreparedStatement) conexao.prepareStatement(comandoSql);
      pst.setObject(1, dtoHistorico.getData());
      pst.setObject(2, dtoHistorico.getCodigoUsuario());
      pst.setObject(3, dtoHistorico.getCodigoMusica());
      pst.setInt(4, dtoHistorico.getCodigo());
      return (pst.executeUpdate() > 0 ? true : false);

    } catch (SQLException e) {
      throw new Exception("Não foi possível alterar o historico " + comandoSql + ". ERRO: " + e);
    }
  }
Example #2
0
  public Boolean Incluir(DtoHistorico dtoHistorico) throws Exception {

    try {

      if (!VerifiqueConexao()) return false;

      comandoSql = "INSERT INTO HISTORICO(DATA, CODIGOUSUARIO, CODIGOMUSICA) VALUES (?,?,?)";
      pst = (PreparedStatement) conexao.prepareStatement(comandoSql);
      pst.setDate(1, dtoHistorico.getData());
      pst.setInt(2, dtoHistorico.getCodigoUsuario().getCodigo());
      pst.setInt(3, dtoHistorico.getCodigoMusica().getCodigo());
      return (pst.executeUpdate() > 0 ? true : false);

    } catch (Exception e) {
      throw new Exception("Nao foi possivel registrar no historico " + comandoSql + ". ERRO: " + e);
    }
  }