Problems to list BD MYSQL in eclipse

0

I'm having a problem in my Java code when listing the MySQL DB in Eclipse.

It turns out that when I post to list the data, it is listing the information 3 times but when I do SELECT * FROM in MySQL the data is being listed correctly. Can someone help me? Below is the method for listing the data.

public void listarClientes() {

    String sql = "SELECT * FROM locadora.cliente, locadora.endereco";

    try {

        PreparedStatement ps = jdbc.getConexao().prepareStatement(sql);
        ResultSet rs = ps.executeQuery();


        while (rs.next()) {

            System.out.println("Nome: " + rs.getString("nome") + " - Código: " + rs.getString("codigo") + " - Bom pagador: " + rs.getBoolean("seBomPagador")
            + " - Telefone: " + rs.getString("telefone"));

            System.out.println("Tipo de endereço: " + rs.getString("tipo_endereco") + " - Logradouro: " + rs.getString("logradouro") + " - Bairro: "
                    + rs.getString("bairro") + " - Cidade: " + rs.getString("cidade") + " - UF: " + rs.getString("uf") + " - Cep: " + rs.getString("cep"));

            System.out.println();
        }

        System.out.println();


    } catch (Exception e) {
        // TODO: handle exception

        System.out.println("Erro na listagem dos clientes!");
    }

}
    
asked by anonymous 25.06.2018 / 01:20

0 answers