业务层调用数据库时遇到sql异常

java.sql.SQLException: Column count doesn't match value count at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)

错误原因:sql语句里面列的数目与后面的值得数目不一致比如insert into 表名 (field1,field2,field3) values('a','b')这样前面的是三列,后面却只有二个值,这就会出现这个错误的。


com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'sex' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3595)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
at cn.edu.zzuli.dao.StuDaoImpl.insertStu(StuDaoImpl.java:47)
at cn.edu.zzuli.action.InsertStudentAction.execute(InsertStudentAction.java:43)
   
    错误原因数值溢出,mysql中数据库涉及student表sex为bit(1),而实际传值为1或者2,数值溢出

你可能感兴趣的:(java,DAO,sql,mysql,jdbc)