hibernate 老說沒有配方言
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
這句話明明就寫在了配置文件里面,可老是沒有寫
錯誤如下:
Exception in thread "main" org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
name改成"hibernate.dialect"也不行
Hibernate-Version: 3.1.1
mysql -Verison: 4.0.16
用這種方法正確
static {
try {
configuration = new Configuration();
sessionFactory = configuration.configure().buildSessionFactory();
} catch (Throwable ex) {
?
throw new ExceptionInInitializerError(ex);
}
}
這種方式會出現異常
// static {
// try {
// // Create a configuration based on the properties file we've put
// Configuration config = new Configuration();
// config.addClass(Customer.class).addClass(Order.class);
// // Get the session factory we can use for persistence
// sessionFactory = config.buildSessionFactory();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
第二種方式是針對使用properties文件配置hiernate的寫法,使用hibernate.cfg.xml應使用第一種調用方式
或者在hibernate.cfg.xml中加入:
?


?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
