java.sql.SQLException: Field 'id' doesn't have a default value
来源:互联网 发布:快乐十分分析软件 编辑:程序博客网 时间:2024/04/29 23:25
自增长:java.sql.SQLException: Field 'id' doesn't have a default value
今天用Java程序向MySQL数据库中进行数据记录的时候,用的id自增长时,报了异常java.sql.SQLException: Field 'id' doesn't have a default value错误,看了一篇博文,决定按他的方法试试。:其中现在修改了STRICT_TRANS_TABLES,删掉。但是我即时测试了一下(可能无法理会更多细节),总之还是没有成功。这时我想到用数据库直接测试一下,看是否不写自增长的id能够正常插入,结果是可以的。所以,我觉得应该从程序方面进行排查。
最后问题解决了,两点建议:
第一,在mysql数据库中,如果自增长id没有设为Auto Increment,在java程序中就会报java.sql.SQLException: Field 'id' doesn't have a default value错误。
第二,你确定程序中要使用的Table和你在数据库中改的是同一张Table吗?如果你偶然改的是test里的测试表,那么就和我一样悲剧了。。。
阅读全文
0 0
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value .
- Hibernate出现Caused by: java.sql.SQLException: Field 'id' doesn't have a default value原因
- java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- java.sql.SQLException: General error, message from server: "Field 'ID' doesn't have a default value
- java.sql.SQLException: Field 'id' doesn't have a default value
- java.sql.SQLException: Field 'id' doesn't have a default value解决方案
- java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- java.sql.SQLException: Field 'id' doesn't have a default value
- java.sql.SQLException: Field 'id' doesn't have a default value
- 解决异常:Cause: java.sql.SQLException: Field 'id' doesn't have a default value
- java.sql.SQLException: Field 'id' doesn't have a default value解决方法
- java.sql.SQLException: Field 'IS_STOREDASSUBDIRECTORIES' doesn't have a default value
- java.sql.SQLException: Field 'Qid' doesn't have a default value
- 2 编写控制器
- 缩略图Thumbnail
- 数据库数据类型
- POJ-2562-Primary Arithmetic
- 获取时间间隔
- java.sql.SQLException: Field 'id' doesn't have a default value
- 数据结构——1.2抽象数据类型
- mouce 和 rad的区别
- Jsonp的实现js跨域
- Selenium之常见元素处理系列二--check
- Android Studio:64K问题com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
- 熵值法
- 光环国际PMP:如何成为团队的佼佼者
- 关于中文乱码问题总结----java