java如何更新数据库_Java 更新数据库,急!

我的数据库中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

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值