mysql报错:java.sql.SQLException: Field 'id' doesn't have a default value

mysql报错:java.sql.SQLException: Field ‘id’ doesn’t have a default value

数据库增加数据报错:java.sql.SQLException: Field ‘id’ doesn’t have a default value
原因是表的id属性没有设置自动递增。

java.sql.SQLException: Field 'id' doesn't have a default value
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3978)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3914)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2495)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1903)
	at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2124)
	at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2058)

在设计表的时候,id作为主键勾选自动递增即可解决此问题。
mysql报错:java.sql.SQLException: Field 'id' doesn't have a default value_第1张图片

你可能感兴趣的:(Java_Exception)