public class EnderecoDAO {
public Endereco getEndereco(String codigo) {
Connection conexao = Conexao.getSqlConnection();
Endereco endereco = new Endereco();
try {
Statement statement = conexao.createStatement();
statement.executeQuery("SELECT * " +
"FROM endereco " +
"WHERE codigoPessoa = " + codigo);
ResultSet resultSet = statement.getResultSet();
while (resultSet.next()) {
Pessoa pessoa = new Pessoa();
pessoa.setCodigoPessoa(resultSet.getInt("codigoPessoa"));
endereco = new Endereco(
resultSet.getString("logradouro"),
resultSet.getString("numero"),
resultSet.getString("bairro"),
resultSet.getString("cep"),
resultSet.getString("complemento"),