標籤:文章 src timezone figure rds new unknown www 連接字串
1. java.sql.SQLException: The server time zone value ‘?й???????‘ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configu
出現該問題,是因為時區沒有指定,需要在連接字串上加上 serverTimezone=UTC
最終的連結語句是 jdbc:mysql:///demo-hibernate?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
2. org.hibernate.MappingException: Unknown entity: DBModel.Students
出現該問題,有好幾個原因,有些是設定檔的引用問題,如果說我們在cfg.xml中點擊hbm.xml能跳轉到相應的檔案,說明引用沒問題。
我出現這個問題是應為hibernate的版本問題,類庫用的高版本,代碼裡面還是用的舊的寫法
我一開始是這麼寫的
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();
後來看到這篇文章 http://www.imooc.com/wenda/detail/339079 改成了
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).configure().build();
問題就沒了
3.org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [*.hbm.xml]
這個錯誤是因為 cfg.xml檔案中<mapping />的配置問題,檢查一下是不是有單詞拼字錯誤
4.org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found : *.hbm.xml : origin(*.hbm.xml)
這個問題比較噁心,原來我配置原件都是放在src下面的 後來看了這篇文章 http://stackoverflow.com/questions/7127608/org-hibernate-mappingnotfoundexception-resource-hbm-xml-not-found 有所感悟,我看了下編譯後的檔案(traget檔案夾下)確實沒有hibernate的設定檔,後來加了一個 resources 檔案夾,把配置都放到該檔案下,再在build path添加一下就好了
hibernate學習手記(1)