Erro

1 resposta
H

Olá galera algume pode me ajuda estou com erro listarentosContasreceber , na linha onde esta rec.setFormadepagamentoidFormadePagamento(rs.getInt("")); ela não ta reconhecendo getIdFormadePagamento com int

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Controle;

import Dal.ConnectMysql;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import model.Contasreceber;

/**
 *
 * @author 'LuizCarlos
 */
public class ContasReceberControle {
    
    PreparedStatement pstm;
    ResultSet rs;
    String consultarContasReceber = ""; // Cunsultar Clientes
    String cadastrarContasReceber = "";
    String alteraContasReceber = "";
    
    
    public void cadastrarPagamento(Contasreceber receber) {
        try {
            ConnectMysql mysql = new ConnectMysql();
            pstm = mysql.Connectar().prepareStatement(cadastrarContasReceber);
            pstm.setString(1, receber.getVencimento());
            pstm.setString(2, receber.getDataPagamento());
            pstm.setDouble(3, receber.getValor());
            pstm.setInt(4, receber.getFormadepagamentoidFormadePagamento().getIdFormadePagamento());
            pstm.setInt(3, receber.getClientesidCliente().getIdCliente());
            pstm.executeUpdate();
            mysql.desconectar();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    
    public void alteraPagamento(Contasreceber receber) {
        try {
            ConnectMysql mysql = new ConnectMysql();
            pstm = mysql.Connectar().prepareStatement(alteraContasReceber);
            pstm.setString(1, receber.getVencimento());
            pstm.setString(2, receber.getDataPagamento());
            pstm.setDouble(3, receber.getValor());
            pstm.setInt(4, receber.getFormadepagamentoidFormadePagamento().getIdFormadePagamento());
            pstm.setInt(3, receber.getClientesidCliente().getIdCliente());
            pstm.setInt(6, receber.getIdContasReceber());
            pstm.executeUpdate();
            mysql.desconectar();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    
    public List<Contasreceber> listarentosContasreceber(String nome) {
        List<Contasreceber> pagamentos = new ArrayList();
        try {
            ConnectMysql mysql = new ConnectMysql();
            pstm = mysql.Connectar().prepareStatement(consultarContasReceber);
            pstm.setString(1, nome); //slect nome
            rs = pstm.executeQuery();
            Contasreceber rec;
            while (rs.next()) {
                rec = new Contasreceber();
                rec.setIdContasReceber(rs.getInt(""));
                rec.setValor(rs.getDouble(""));
                rec.setVencimento(rs.getString(""));
                rec.setDataPagamento(rs.getString(""));
                rec.setFormadepagamentoidFormadePagamento(rs.getInt(""));
                
                pagamentos.add(rec);
            }

            mysql.desconectar();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return pagamentos;
    }
}

Classe Contas receber

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
*
* @author 'LuizCarlos
*/
@Entity
@Table(name = "contasreceber")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Contasreceber.findAll", query = "SELECT c FROM Contasreceber c"),
@NamedQuery(name = "Contasreceber.findByIdContasReceber", query = "SELECT c FROM Contasreceber c WHERE c.idContasReceber = :idContasReceber"),
@NamedQuery(name = "Contasreceber.findByVencimento", query = "SELECT c FROM Contasreceber c WHERE c.vencimento = :vencimento"),
@NamedQuery(name = "Contasreceber.findByValor", query = "SELECT c FROM Contasreceber c WHERE c.valor = :valor"),
@NamedQuery(name = "Contasreceber.findByDataPagamento", query = "SELECT c FROM Contasreceber c WHERE c.dataPagamento = :dataPagamento")})
public class Contasreceber implements Serializable {
@JoinColumn(name = "clientes_idCliente", referencedColumnName = "idCliente")
@ManyToOne(optional = false)
private Clientes clientesidCliente;
@JoinColumn(name = "formadepagamento_idFormadePagamento", referencedColumnName = "idFormadePagamento")
@ManyToOne(optional = false)
private Formadepagamento formadepagamentoidFormadePagamento;
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "idContasReceber")
private Integer idContasReceber;
@Column(name = "vencimento")
private String vencimento;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Column(name = "valor")
private Double valor;
@Column(name = "dataPagamento")
private String dataPagamento;

public Contasreceber() {
}

public Contasreceber(Integer idContasReceber) {
this.idContasReceber = idContasReceber;
}

public Integer getIdContasReceber() {
return idContasReceber;
}

public void setIdContasReceber(Integer idContasReceber) {
this.idContasReceber = idContasReceber;
}

public String getVencimento() {
return vencimento;
}

public void setVencimento(String vencimento) {
this.vencimento = vencimento;
}

public Double getValor() {
return valor;
}

public void setValor(Double valor) {
this.valor = valor;
}

public String getDataPagamento() {
return dataPagamento;
}

public void setDataPagamento(String dataPagamento) {
this.dataPagamento = dataPagamento;
}

@Override
public int hashCode() {
int hash = 0;
hash += (idContasReceber != null ? idContasReceber.hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Contasreceber)) {
return false;
}
Contasreceber other = (Contasreceber) object;
if ((this.idContasReceber == null && other.idContasReceber != null) || (this.idContasReceber != null && !this.idContasReceber.equals(other.idContasReceber))) {
return false;
}
return true;
}

@Override
public String toString() {
return "model.Contasreceber[ idContasReceber=" + idContasReceber + " ]";
}

public Clientes getClientesidCliente() {
return clientesidCliente;
}

public void setClientesidCliente(Clientes clientesidCliente) {
this.clientesidCliente = clientesidCliente;
}

public Formadepagamento getFormadepagamentoidFormadePagamento() {
return formadepagamentoidFormadePagamento;
}

public void setFormadepagamentoidFormadePagamento(Formadepagamento formadepagamentoidFormadePagamento) {
this.formadepagamentoidFormadePagamento = formadepagamentoidFormadePagamento;
}

}

1 Resposta

ViniGodoy

Seu set não foi declarado como int, como espera que ele aceite um int?

public void setFormadepagamentoidFormadePagamento(Formadepagamento formadepagamentoidFormadePagamento) { this.formadepagamentoidFormadePagamento = formadepagamentoidFormadePagamento; }

Criado 5 de junho de 2015
Ultima resposta 25 de jul. de 2015
Respostas 1
Participantes 2