我正在尝试使用null
值更新某些属性。但它总是错误的。这是我的代码
// deleting records of column overtime, medical, bonus, other and totalamount
try {
String deleteQuery = "update paydb.allowance set "
+ "overtime = ?, "
+ "medical = ?,"
+ "bonus = ?,"
+ "other = ?,"
+ "totalamount = ?"
+ "where emp_id = ?";
PreparedStatement dpst = conn.prepareStatement(deleteQuery);
dpst.setNull(1, java.sql.Types.DOUBLE);
dpst.setNull(2, java.sql.Types.DOUBLE);
dpst.setNull(3, java.sql.Types.DOUBLE);
dpst.setNull(4, java.sql.Types.DOUBLE);
dpst.setNull(5, java.sql.Types.DOUBLE);
dpst.setString(6, txt_search.getText());
dpst.executeUpdate();
JOptionPane.showMessageDialog(null, "Record deleted successfully");
}
catch (SQLException e)
{
JOptionPane.showMessageDialog(null, e);
}
答案 0 :(得分:0)
try {
String deleteQuery = "update paydb.allowance set "
+ "overtime = ?,"
+ "medical = ?,"
+ "bonus = ?,"
+ "other = ?, "
+ "totalamount = ? "
+ "where emp_id = ? ";
enter code here
PreparedStatement dpst = conn.prepareStatement(deleteQuery);
dpst.setNull(1, java.sql.Types.DOUBLE);
dpst.setNull(2, java.sql.Types.DOUBLE);
dpst.setNull(3, java.sql.Types.DOUBLE);
dpst.setNull(4, java.sql.Types.DOUBLE);
dpst.setNull(5, java.sql.Types.DOUBLE);
dpst.setString(6, txt_search.getText());
dpst.executeUpdate();
JOptionPane.showMessageDialog(null, "Record deleted successfully");
}
catch (SQLException e)
{
JOptionPane.showMessageDialog(null, e);
}