Olá pessoal,
eu estava fazendo uns teste aqui em casa,
mas fiquei com uma dúvida eu fi z o seguinte método:
public Contato pesquisar(int id) throws SQLException{
PreparedStatement stmt = this.connection.prepareStatement("SELECT * FROM contatos WHERE id=?");
stmt.setInt(1, id);
ResultSet rs = stmt.executeQuery();
String nome = rs.getString(2);
String email = rs.getString(3);
String endereco = rs.getString(4);
rs.close();
stmt.close();
return new Contato(id, nome, email, endereco);
}
Mas toda hora aparece a seguinte mensagem:
java.sql.SQLException
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:815)
at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5528)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5448)
at br.com.caelum.jdbc.dao.ContatoDao.pesquisar(ContatoDao.java:70)
at br.com.caelum.jdbc.dao.TestaPesquisarDao.main(TestaPesquisarDao.java:13)
CONSTRUÍDO COM SUCESSO (tempo total: 1 segundo)
Será que alguém poderia me dar uma ajuda?
[]'s.