一個發佈公告的功能 mysql
在其餘電腦上面運行的好好的。到了另一臺上就出問題了, sql
報以下錯誤 數據庫
[http-8080-2] ERROR org.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) org.hibernate.AssertionFailure: null id in分別用英文和中文插入,發現英文能行,(don't flush the Session after an exception occurs)
插入中文老是失敗,因而懷疑是否數據庫編碼問題了,在Navicat上面直接保存中文,被拒絕保存。用下面語句查看mysql的編碼格式 session
查看mysql的編碼格式 show variables like 'character_set_%'; this
果真,顯示的都是latin1編碼。問題就好解決了。 編碼
在C盤,我裝MYSQL在這裏,找到C:\Program Files\MySQL\MySQL Server 5.5\bin hibernate
下面的MySQLInstanceConfig.exe,點擊運行,而後一路next,直到選擇編碼的時候:如圖 code
記得在第3個上面打鉤!而後選擇utf-8編碼 utf-8
而後繼續一路next,從新配置之後,能夠插入中文了。 io