public List<Cliente> listAll() throws SQLException { List<Cliente> lista = new ArrayList<Cliente>(); try (Connection conexao = new ConnectionFactory().getConnection()) { StringBuilder query = new StringBuilder(); query.append(" select idCliente, nmCliente, nrCpf from Cliente"); PreparedStatement statement = conexao.prepareStatement(query.toString()); ResultSet resultSet = statement.executeQuery(); while (resultSet.next()) { Cliente cliente = new Cliente(); cliente.setIdCliente(resultSet.getLong(1)); cliente.setNmCliente(resultSet.getString(2)); cliente.setNrCpf(resultSet.getString(3)); lista.add(cliente); } } catch (SQLException e) { throw e; } return lista; }