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;

就完事了!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章