我需要檢查數據庫中是否存在數據庫下的匯款ID,如果該框不存在,那麼我輸入那麼我需要顯示消息,該框不存在,但如果它不將它應該插入新的對話框我已經寫了一些代碼,但它的示值誤差檢查數據庫中是否存在該記錄
private void txtboxnoFocusLost(java.awt.event.FocusEvent evt) {
DBUtil util = new DBUtil();
try {
Connection con = util.getConnection();
PreparedStatement stmt = con.prepareStatement(
"select box_no from dbo.soil_det where rm_id = ? and box_no = ?");
stmt.setLong(1, Long.parseLong(tf_rm_id.getText()));
stmt.setString(1, (txtboxno.getText()));
ResultSet rs=stmt.executeQuery();
while(rs.next()){
rs.equals().txtboxno.getText());
}
JOptionPane.showMessageDialog(rootPane, "hello!S");
} catch (Exception ex) {
Logger.getLogger(DATAENTRY.class.getName()).log(Level.SEVERE, null, ex);
}
它可能應該stmt.setString(2,... – pgras
其實有什麼錯誤,你都拿到? – Rahul