java.sql.SQLException: Field ‘userID‘ doesn‘t have a default value at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2921) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1570) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665) at com.mysql.jdbc.Connection.execSQL(Connection.java:2972) at com.mysql.jdbc.Connection.execSQL(Connection.java:2902) at com.mysql.jdbc.Statement.executeUpdate(Statement.java:929) at Demo2.demo2.main(demo2.java:30)
这个问题的出现主要是因为数据库的属性userID没有进行声明
String userID = null;
String sql = "insert into user(userID,userName,password) values(‘"+userID+"‘,‘"+userName+"‘,‘"+password+"‘)";
时间: 2024-11-05 05:55:10