Java 提交表单时出错:数据截断:日期时间不正确

Java 提交表单时出错:数据截断:日期时间不正确,java,mysql,jsp,jakarta-ee,servlets,Java,Mysql,Jsp,Jakarta Ee,Servlets,我在我的表格生效时得到了这个例外 dao.DAOException: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '\xAC\xED\x00\x05sr\x00\x1Acom.sun.jmx.snmp.Timestamp\xFC\xA2\x9Fq\xB8z\xE9!\x02\x00\x04J\x00\x06crtimeJ\x00\x09sysUpTimeL\x00\x0' for c

我在我的表格生效时得到了这个例外

dao.DAOException: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '\xAC\xED\x00\x05sr\x00\x1Acom.sun.jmx.snmp.Timestamp\xFC\xA2\x9Fq\xB8z\xE9!\x02\x00\x04J\x00\x06crtimeJ\x00\x09sysUpTimeL\x00\x0' for column 'date' at row 1
at dao.CommandeDaoImpl.creer(CommandeDaoImpl.java:55)
at forms.InscriptionCommandeForm.inscrireCommande(InscriptionCommandeForm.java:95)
at servlets.Commande.doPost(Commande.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
相关类别的代码部分CommandeDaoImpl:

public void creer(CommandeBean commande) throws DAOException {
    Connection connexion = null;
    PreparedStatement preparedStatement = null;
    ResultSet valeurAutoGenerees = null;
    try{
        connexion = daoFactory.getConnection();
        preparedStatement = DAOUtilitaire.initialisationRequetePreparee(
                connexion, SQL_INSERT, true, commande.getClient().getId(),
                new Timestamp( commande.getDate().getMillis()),
                commande.getMontant(), commande.getModePaiement(), commande.getStatutPaiement(),
                commande.getModeLivraison(), commande.getStatutLivraison());

        int statut = preparedStatement.executeUpdate();
        if(statut == 0){
            throw new DAOException("Echec de la creation de la commande, aucune ligne ajoutée dans la table.");
        }
        valeurAutoGenerees = preparedStatement.getGeneratedKeys();
        if(valeurAutoGenerees.next()){
            commande.setId( valeurAutoGenerees.getLong(1));
        }else{
            throw new DAOException("Échec de la création de la commande en base,"
                    + " aucun ID auto-généré retourné.");
        }
    }catch(SQLException e){
        throw new DAOException(e);
    }finally{
        DAOUtilitaire.fermeturesSilencieuses(valeurAutoGenerees, preparedStatement, connexion);
    }
}
注:这两条路线涉及两类不同的项目: 在forms.edintingcommandeform.inscrimrecommend(edintingcommandeform.java:95)中 位于servlets.Commande.doPost(Commande.java:50)

编辑:

    SQL_INSERT = "INSERT INTO commande (
id_client, 
date, 
montant, 
mode_paiement, 
statut_paiement, 
mode_livraison, 
statut_livraison) 
VALUES (?, ?, ?, ?, ?, ?, ?)";


嘿,你应该检查你的时间戳

java.sql.Timestamp
他们的错误如下:(他们的日期值太错误)


mysql中的dateTime类型是什么?类型是dateTime,我在项目中使用的是jodaTime jar。您可以发布表结构并插入查询吗?首先检查用于
时间戳的库。它应该是
java.sql.Timestamp
。因为有
com.sun.jmx.snmp.Timestamp
错误。所以它可能引用了错误的库。是的,解决它的人谢谢,我怎样才能给你们最好的答案打分???
java.sql.Timestamp
com.sun.jmx.snmp.Timestamp .