2017-07-04 113 views
0

我得到這個錯誤在我的Hibernate桌面應用程序:初始SessionFactory的創建failed.org.hibernate.service.spi.ServiceException:無法創建請求的服務

Initial SessionFactory creation failed.org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] 

它沒有創造SessionFactory,給這個異常:

Executing E:\Vishal\summer\EmpMan\dist\run1432002073\EmpMan.jar using platform C:\Program Files (x86)\Java\jdk1.8.0_131\jre/bin/java 
Jul 04, 2017 2:24:35 PM org.hibernate.Version logVersion 
INFO: HHH000412: Hibernate Core {5.2.10.Final} 
Jul 04, 2017 2:24:35 PM org.hibernate.cfg.Environment <clinit> 
INFO: HHH000206: hibernate.properties not found 
Jul 04, 2017 2:24:35 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> 
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 
Jul 04, 2017 2:24:35 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure 
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) 
Jul 04, 2017 2:24:35 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator 
INFO: HHH10001005: using driver [org.h2.Driver] at URL [jdbc:h2:~/EmpMan] 
Jul 04, 2017 2:24:35 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator 
INFO: HHH10001001: Connection properties: {user=sa, password=****} 
Jul 04, 2017 2:24:35 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator 
INFO: HHH10001003: Autocommit mode: false 
Jul 04, 2017 2:24:35 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init> 
INFO: HHH000115: Hibernate connection pool size: 1 (min=1) 
Initial SessionFactory creation failed.org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] 

就是這樣。我只得到這麼多的信息。

的hibernate.cfg.xml文件配置:

<hibernate-configuration> 

    <session-factory> 

     <!-- Database connection settings --> 
     <property name="connection.driver_class">org.h2.Driver</property> 
     <property name="connection.url">jdbc:h2:~/EmpMan</property> 
     <property name="connection.username">sa</property> 
     <property name="connection.password">sa</property> 

     <!-- JDBC connection pool (use the built-in) --> 
     <property name="connection.pool_size">1</property> 

     <!-- SQL dialect --> 
     <property name="dialect">org.hibernate.dialect.H2Dialect</property> 

     <!-- Disable the second-level cache --> 
     <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> 

     <!-- Echo all executed SQL to stdout --> 
     <property name="show_sql">true</property> 

     <!-- Drop and re-create the database schema on startup --> 
     <property name="hbm2ddl.auto">create</property> 

     <!-- Names the annotated entity class --> 
     <mapping class="models.AdminDetails"/> 
     <mapping class="models.EmployeeDetails" /> 
     <mapping class="models.DepartmentDetails" /> 
     <mapping class="models.DailyDataDetails"/> 
    </session-factory> 

</hibernate-configuration> 

注意:

=>我使用H2數據庫,我想配置嵌入式數據庫

=>我使用NetBeans和Java8與休眠版本5.2.10

=>我是新來的h2數據庫

=>我的項目中哪裏可以找到我的EmpMan數據庫?

回答

0

問題解決:我已經存在相同的命名數據庫,所以我改了名字,現在它的工作:)謝謝你們

相關問題