jdbc - movenext button not working in java -
private void btn_nextactionperformed(java.awt.event.actionevent evt) { try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); connect =drivermanager.getconnection("jdbc:odbc:reimbursement"); } catch(exception e) { system.out.println(e.getmessage()); } try { stmt = connect.createstatement(resultset.type_scroll_insensitive, resultset.concur_updatable ); sql = "select * reimbursementmaster"; rs = stmt.executequery( sql ); rs=stmt.getresultset(); if(rs.next()) { empcode=rs.getstring("employeecode"); empname=rs.getstring("employeename"); loc=rs.getstring("location"); location=loc; } else { rs.previous(); joptionpane.showmessagedialog(this, "end of file","message",joptionpane.information_message ); } } catch(sqlexception e) { system.out.println(e.getmessage()); }
}
let me guess...
problem getting first result times because resultset reopened scratch every time press next button.
- declare
resultset rs
class member, - open
rs
out ofbtn_nextactionperformed()
(where build ui can place) ,rs.next()
should work expected.
Comments
Post a Comment