Olá estou com dificuldade em criar alguns métodos (primeiro, anterior, próximo, ultimo), usando o Statement conseguiria fazendo algo assim…
private Connection con;
private Statement stmt;
private ResultSet rsNavegar;
private Statement stmtNavegar;
public AlunoDAO() throws ClassNotFoundException, SQLException {
con = FactoryConect.getConnection();
stmt = con.createStatement();
stmtNavegar = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
rsNavegar = stmtNavegar.executeQuery("select * from aluno");
}
public Aluno primeiro() throws SQLException {
if (rsNavegar.first()) {
Aluno aluno = new Aluno();
aluno.setCod(rsNavegar.getInt("cod"));
aluno.setNome(rsNavegar.getString("nome"));
aluno.setSobrenome(rsNavegar.getString("Sobrenome"));
aluno.setIdCidade(rsNavegar.getInt("idcidade"));
return aluno;
} else {
return null;
}
}
mas e com o prepareStatement tem como fazer ? se sim alguém pode dar um exemplo?