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 * from 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());
}
}
答案 0 :(得分:0)
让我猜一下......
您的问题是您始终只得到第一个结果,因为每次按下下一个按钮时都会从头开始重新打开结果集。
Resultset rs
声明为类成员,rs
btn_nextActionPerformed()
(您构建用户界面)
可以是一个好地方)rs.next()
应该按预期工作。