gpt4 book ai didi

java - 数据截断: incorrect data value : 'yyyy MMM d' for column 'date_acd' at row 1

转载 作者:行者123 更新时间:2023-11-29 20:53:14 26 4
gpt4 key购买 nike

您好,我的程序中出现此错误,但我找不到解决方案。这是我的代码,请跟随我:

private void bt2ActionPerformed(java.awt.event.ActionEvent evt) {                                    
try{

if (JOptionPane.showConfirmDialog(null,"confirmer la modification ","modification sur un departement",
JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) {
st.execute("Update departement set code_departement = '"+txtcode.getText()+"',nom_departement = '"+txtnom.getText()
+"',date_acd = '"+jdat.getDateFormatString()+"' where code_departement = "+txtcode.getText());
AfficherDepartement();
}

} catch(Exception e) {JOptionPane.showMessageDialog(null,"erreur de modifier le departement !!!!\n"+e.getMessage());
System.err.println(e);}

最佳答案

在设置为查询之前,将日期格式化为'yyyy-MM-dd'。您可以使用它

java.text.SimpleDateFormat

类。

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String date = sdf.format(new Date());

关于java - 数据截断: incorrect data value : 'yyyy MMM d' for column 'date_acd' at row 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37850554/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com