@Override
    public Funcao listById(int id) {

        Connection conn = null;
        PreparedStatement pstm = null;
        ResultSet rs = null;
        Funcao f = new Funcao();

        try {
            conn = ConnectionFactory.getConnection();
            pstm = conn.prepareStatement(LISTBYID);
            pstm.setInt(1, id);
            rs = pstm.executeQuery();

            while (rs.next()) {

                f.setCodigo(rs.getInt("codigo"));
                f.setNome(rs.getString("nome"));

            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Erro ao listar" + ex.getMessage());

        } finally {

            try {
                ConnectionFactory.closeConnection(conn, pstm, rs);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "Erro ao fechar conexão" + ex.getMessage());
            }
        }
        return f;

    }