我在Hibernate桌面应用程序中遇到此错误:
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>
注意:
=&GT;我正在使用h2数据库,我想配置嵌入式数据库
=&GT;我正在使用netbeans和Java8与hibernate版本5.2.10
=&GT;我是h2数据库的新手
=&GT;在我的项目中何处找到我的EmpMan数据库?
答案 0 :(得分:0)
解决问题:我已经存在同名的数据库,所以我更改名称,现在它正在工作:)谢谢你们