public int buscarIdForma(String nome) { Connection con; PreparedStatement stmt; try { con = ConexaoMySQL.conectar(); stmt = con.prepareStatement(SQL_BUSCAR_FORMA_PAGAMENTO_DESCRICAO); stmt.setString(1, nome); ResultSet rs = stmt.executeQuery(); while (rs.next()) { return rs.getInt("idforma_pagamento_compra"); } con.close(); } catch (SQLException ex) { } return 0; }
public String buscarNomeForma(int id) { Connection con; PreparedStatement stmt; try { con = ConexaoMySQL.conectar(); stmt = con.prepareStatement(SQL_BUSCAR_FORMA_PAGAMENTO_ID); stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(); while (rs.next()) { return rs.getString("descricao"); } con.close(); } catch (SQLException ex) { } return "Erro"; }