com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'S_ID' in 'field list'

详细报错:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'S_ID' in 'field list'
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_111]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_111]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_111]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_111]

解决方案:

在sid 实体类上Column注解上定义的时候多了一个_然后导致了mysql找不到主键赋值,就报错了

这个是报错的实体类,你会发现是不是多了一个_符号,然后导致了Mysql找不到了标识符

   //报错的根源
    @Id
    @Column(name = "S__ID", unique = true, nullable = false, length = 32)
    private String sId;

修改成:

    @Id
    @Column(name = "S_ID", unique = true, nullable = false, length = 32)
    private String sId;

就完事了!!!

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