Error updating database. Cause: java.sql.BatchUpdateException: Field 'id' doesn't have a default value

异常信息

### Error updating database.  Cause: java.sql.BatchUpdateException: Field ‘id‘ doesn‘t have a default value
Query is: INSERT INTO
         `test`.`order`
        (

         `order`.`code`,
         `order`.`create_date`,
         `order`.`status`,
        )
        VALUES (

         ?,

                                                                ?,

原因

数据库表设计时候id没有加自动增长

mybatis添加后执行了查询id 而报错

<selectKey resultType="long"
                   keyProperty="id"
                   order="AFTER">
            SELECT
            LAST_INSERT_ID()
        </selectKey>

解决方法

把mysql数据库的id设为自增列

Error updating database. Cause: java.sql.BatchUpdateException: Field 'id' doesn't have a default value

时间: 2024-10-29 19:13:30

Error updating database. Cause: java.sql.BatchUpdateException: Field 'id' doesn't have a default value的相关文章

Caused by: java.sql.SQLException: Field &#39;id&#39; doesn&#39;t have a default value

1.错误描述 org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(Sql

java.sql.SQLException: Field &#39;id&#39; doesn&#39;t have a default value(用eclipse操作数据库时报了这种奇怪的错误)的原因与解决方法

1.错误原因 由于id在数据库表中是作为主键,但是在插入的过程中,没有给予数值,并且没有让其自增 2.解决办法 修改数据库表中的id,让其自增(在插入的过程中,不插入id数据时) java.sql.SQLException: Field 'id' doesn't have a default value(用eclipse操作数据库时报了这种奇怪的错误)的原因与解决方法 原文地址:https://www.cnblogs.com/zyt-bg/p/8385972.html

mybatis的报错总结_____2Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the ri

在编写动态sql时 trim的属性写错了,如下图: 错误示范: (接口的xml配置文件中:) 1 <update id="modifyBill" parameterType="Bill"> 2 update smbms_bill 3 <trim suffix="set" prefixOverrides="," prefix="where id=#{id}"> 4 <if tes

Caused by: java.sql.SQLException: Field &#39;category_id&#39; doesn&#39;t have a default value

### The error may involve com.qingmu.core.dao.ad.ContentDao.insertSelective-Inline ### The error occurred while setting parameters ### SQL: insert into tb_content ( title, url, pic, sort_order ) values ( ?, ?, ?, ? ) ### Cause: java.sql.SQLException:

Hibernate中Caused by: java.sql.SQLException: Field &#39;address_id&#39;doesn&#39;t have a default value

在学习Hibernate中,相信很多人都遇到过: Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute statement Caused by: java.sql.SQLException: Field 'address_id' doesn't have a default value 很是纳闷,明明我的address_id是主键,为毛还提示我不存在默认值?主

mybatis的报错____3Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right

仔细查看报错日志中的sql语句: ### SQL: update smbms_bill set billCode=?, productName=?, productDesc=?, where id=? 没错,在where id = ?之前多了一个 逗号,正确姿势,去删掉接口配置文件中 最后一个if标签的逗号. (不得不说 log4j日志打印信息真是好用!) 原文地址:https://www.cnblogs.com/xbfchder/p/11247727.html

mybatis报Error updating database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String

mybatis 3.3.0中对于时间参数进行比较时的一个bug. 如果拿传入的时间类型参数与空字符串''进行对比判断则会引发异常. 所以在上面的代码中去该该判断, 只保留非空判断就正常了 <if test="createTime != null and createTime !='' " >  date(create_time) = date(#{createTime,jdbcType=TIMESTAMP}) </if> 改为 <if test="

【问题排查记录】Field &#39;id&#39; doesn&#39;t have a default value;

错误信息: org.springframework.dao.DataIntegrityViolationException: StatementCallback; SQL [delete from table_a where union_id = 123456789;]; Field 'id' doesn't have a default value; nested exception is java.sql.BatchUpdateException: Field 'id' doesn't ha

Field &#39;id&#39; doesn&#39;t have a default value(jdbc连接错误)

JDBC 连接错误: 编写数据库连接增添数据时,出现以下错误: error : java.sql.SQLException: Field 'id' doesn't have a default value ”id“不具有默认值. 原因: 所建立的数据表中属性”id“,设置的是”不允许为空“.在插入前没有值,不允许进行插入操作. 解决方法: 1.将属性改为”允许为空“ 2.给”id“属性设置一个默认值.   Field 'id' doesn't have a default value(jdbc连