@Override
    public Convenio listById(int codigo) {
        Connection con = null;
        PreparedStatement pstm = null;
        ResultSet rs = null;
        Convenio f = new Convenio();
        try{
            con = ConnectionFactory.getConnection();
            pstm = con.prepareStatement(LISTBYID);
            pstm.setInt(1, codigo);
            rs = pstm.executeQuery();
            while(rs.next()){
                
                f.setCodigo(rs.getInt("codigo"));
                f.setNome(rs.getString("nome"));
                
            }
        }catch(Exception e){
            JOptionPane.showMessageDialog(null, "Erro ao listar convenio(id): "+e.getMessage());
        }finally{
            try{
                ConnectionFactory.closeConnection(con, pstm, rs);
            } catch (SQLException ex) {
                JOptionPane.showMessageDialog(null, "Erro ao fechar conexão do listar: "+ex.getMessage());
            }
        }
        return f;
    }