Bom to Fazendo um sistema aki, tava fazendo com DAO. mas eu n to conseguindo fazer essa parte, entao vo faze nakelas, dps eu vo ajeitando…
Tipo To precisando mostrar os dados nos campos e com os botoes pra passar os registros pra frente, pra traz talz…
So q qdo eu clico la, da um erro falando:
[quote] Operação requer um ResultSet rolável, mas este ResultSet é FORWARD_ONLY (somente para frente).
[/quote]
N tenho nem ideia como q eu faço pra ajeita.
Alguem pod me da um força…
Tipo assim:
public void TrazerDados(){
try{
Connection c = ConnectionFactory.CriarConexao();
String sql = "Select * From Funcionario where Fun_Nome like ?";
ps = c.prepareStatement(sql);
ps.setString(1, txtBusca.getText().toUpperCase() + "%");
rs = ps.executeQuery();
rs.first();
atualizaCampos();
}
catch (SQLException e) {
e.printStackTrace();
}
}
public void atualizaCampos(){
try{
txtNome.setText(rs.getString("fun_nome"));
txtEnd.setText(rs.getString("fun_end"));
txtNum.setText(rs.getString("fun_num"));
txtBai.setText(rs.getString("fun_bai"));
txtCid.setText(rs.getString("fun_cid"));
jcombo1.setSelectedItem(rs.getString("fun_est"));
txtTel.setText(rs.getString("fun_tel"));
txtCel.setText(rs.getString("fun_cel"));
txtRg.setText(rs.getString("fun_rg"));
txtCpf.setText(rs.getString("fun_cpf"));
txtCargo.setText(rs.getString("fun_car"));
txtSala.setText(rs.getString("fun_sala"));
txtDataNasc.setText(rs.getString("fun_dtnasc"));
txtEmail.setText(rs.getString("fun_email"));
}
catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void actionPerformed(ActionEvent e) {
try{
if(e.getSource() == btnFirst){
rs.first();
atualizaCampos();
}
if(e.getSource() == btnPrevious){
rs.previous();
atualizaCampos();
}
if(e.getSource() == btnNext){
rs.next();
atualizaCampos();
}
if(e.getSource() == btnLast){
rs.last();
atualizaCampos();
}
}
catch (SQLException ex) {
ex.printStackTrace();
}
}