我的数据库中birthday是Date类型,在图形界面中的文本域中输入日期进行查询,即使我跟数据库中输入的一模一样,它还是提示与标准类型不符,咋办?以下是错误提示Exceptioninthread"AW...
我的数据库中birthday是Date类型,在图形界面中的文本域中输入日期进行查询,即使我跟数据库中输入的一模一样,它还是提示与标准类型不符,咋办?
以下是错误提示
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "2010-01-23 00:00:00"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at courseDesign2.ModifyRecord.actionPerformed(ModifyRecord.java:192)
以下是部分代码
if(e.getSource()==enterModify){
try{
babycode = txt_babycode.getText();
address = txt_address.getText();
postcode = txt_postcode.getText();
mother = txt_mother.getText();
father = txt_father.getText();
babysex = txt_babysex.getText();
babyweight = Double.parseDouble(txt_babyweight.getText());
nursecode = txt_nursecode.getText();
birthday = new Date(Long.parseLong(txt_birthday.getText()));
con = DriverManager.getConnection("jdbc:odbc:hello","","");
sql = con.createStatement();
String mysql;
mysql = "UPDATE message3 SET address='"
+ address + "',postcode='" + postcode
+ "',mother='" + mother + "',father='"
+ father + "',babysex='" + babysex
+ "',babyweight='" + babyweight + "',nursecode='"
+ nursecode + "',birthday='" + birthday
+ "'WHERE babycode='" + num + "'";
int k = sql.executeUpdate(mysql);
if (k == 1)
JOptionPane.showMessageDialog(this, "更新成功", "成功",
JOptionPane.PLAIN_MESSAGE);
con.close();
} catch (SQLException ee) {
JOptionPane.showMessageDialog(this, "更新失败" + ee, "失败",
JOptionPane.ERROR_MESSAGE);
}
}
注意:我的数据库中birthday没有00:00:00
展开