报的错是:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax 把sql语句改成insert  into c (id,name,age) values(null,?,?)就不报错了,这是为什么吗啊

解决方案 »

  1.   

    你的ID是主键吗, 不管怎样主键是不能没有的,哪怕为null都行,这也就是为什么你的第二条不会有错,因为你给主键赋值了,系统不管你赋的值是什么,总之不能没有主键,就是插入的时候必须为主键赋值
      

  2.   

    id自增,插入的时候就不需要插入ID这个字段了。
    insert into c (name,age) values(?,?)
      

  3.   

    如果id是要自增的,在数据库里把它的identity specification属性设为yes就可以了啊,不能插入的
      

  4.   

    说明楼主的ID不是自增的 调一下就好 也可以在数据库操作看看是不是自增的 楼主在数据库中填写后两个数据看看ID是不是自增
      

  5.   

    ID自增 在INSERT的时候就不要把ID字段写进去就行了
      

  6.   

    insert into c (name,age) values(?,?)创建表的时候  mysql  : create  table c( id int auto_increment primary key, 
                                           name varchar(20),
                                           age int) ;就行啦
      

  7.   

    id int auto_increment primary key,