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); } }