插入数据时候有个字段总是插不进数据然后报错
严重: Servlet.service() for servlet default threw exception
java.sql.BatchUpdateException: Column 'firstname' cannot be null

at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1269)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:955)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)

解决方案 »

  1.   

    Column 'firstname' cannot be null
    说了很清楚啊
    看看是不是页面上的字段写错了
      

  2.   

    不能为空,数据库字段有约束,不能为空, 插入语句时firstname时空值
      

  3.   

    对,mysql数据库的这个表的那个字段建表的时候设置为not null 了,异常已经说得很清楚了
      

  4.   

    java.sql.BatchUpdateException: Column 'firstname' cannot be null 
    这句话怎么翻译?
      

  5.   

    数据库中应该设置为不许为null,不然的话可以插入,只不过插入的值都是null,那不就是逻辑上的错误了么
    昨天查了很久配置,也没查出来
      

  6.   

    还有一个问题出现了,就是mysql数据库出现了乱码,网上还有我的一些朋友说把前台页面设置为UTF-8,然后再把mysqld的默认CharacterEncoding设置为UTF-8,我都设置了,我甚至链my.ini.bac的都改过来了可是还是乱码,我想我一定是有那个细节有问题,请大家帮忙给点建议,用UTF-8统一编码是最好的解决方案,其他方式就不需要了
      

  7.   

    你先看一下数据库安装的my.ini里面的client客户端设置的是什么,好像一般是utf-8,不过数据库用的是gbk
    所以在MySQL里面就设置一下 set  names gbk.这样应该就可以了。
    以前插入的数据因为已经乱码了,所以没法解决了!
    我以前数据库乱码一般是这样解决。你试一下吧
      

  8.   

    说白了 firstname 不能为空 你在对数据库进行操作的时候 这个字段是空值
      

  9.   

    mysql 里也要设置UTF-8的 要不也会乱码