2016-12-14 66 views
-3

在基於hibernate的程序中進行編程時發生以下異常com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExceptioncom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException在hibernate程序中請求檢查mysql版本

MySql版本是5.7.9,我的方言是org.hibernate.dialect.MySQLDialect。

+0

試着用'org.hibernate.dialect.MySQL5Dialect' – SachinSarawgi

+0

我也試圖與org.hibernate.dialect.MySQL5Dialect但錯誤仍正在添加 –

+1

請發表您的錯誤堆棧和JDBC配置。 – SachinSarawgi

回答

0

對於構建SessionFactory對象,請使用下面的代碼片段,並確保您有hibernate.cfg.xml在classpath中。

try 
{ 
    Configuration configuration = new Configuration(); 
    configuration.configure(); 
    SessionFactory sessionFactory = configuration 
       .buildSessionFactory(new StandardServiceRegistryBuilder() 
         .applySettings(configuration.getProperties()) 
         .build()); 
} catch (Exception e) { 
    e.printStackTrace(); 
    throw new RuntimeException(
      "There was an error building the factory"); 
} 
相關問題