String v1=lbl_READING_NUMBER.getText();
String v2=jTextField4.getText();
try{
String sql1 = "UPDATE reading set Previous_reading='"+v2+"' where
Reading_Number='"+v1+"'";
ps=conn.prepareStatement(sql1);
ps.executeUpdate();
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}try{
String sql = "SELECT * FROM reading WHERE Reading_number = ?";
ps1 = conn.prepareStatement(sql);
ps1.setString(1, lbl_READING_NUMBER.getText());
rs =ps1.executeQuery();
String add1 = rs.getString("Previous_reading");
lbl_READING_NUMBER.setText(add1);
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
问题是当我执行此错误时说:java.sql.SQLException:在结果集开始之前
rs =ps1.executeQuery();
在此行使用之后
while (rs.next()){
String add1 = rs.getString("Previous_reading");
}
java.sql.SQLException:在结果集开始之前,表示指针在行之前。next(( 将光标从其在结果集中的当前位置移动一行。初始它的位置在第一行之前