我想使用OS身份验证来使用hibernate 5连接到Oracle数据库。下面是我正在使用的hibernate.cfg.xml的相关部分。
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.username"></property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@:1521:IMADB</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.show_sql">false</property>
<property name="connection.autocommit">true</property>
<property name="hibernate.connection.release_mode">on_close</property>
</session-factory>
我得到的错误是
2018-03-08 13:20:21错误HibernateUtil:20 - 初始SessionFactory创建失败。 org.hibernate.service.spi.ServiceException:无法创建请求的服务[org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] 在org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:271) 在org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) 在org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) 在org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) 在org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) 在org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) 在org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) 在org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) 在org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418) 在org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87) 在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:691) 在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726) 在com.rca.ie.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:15) 在com.rca.ie.util.HibernateUtil。(HibernateUtil.java:10) 在com.rca.ie.business.TestIeTables.main(TestIeTables.java:14) 引起:org.hibernate.exception.JDBCConnectionException:调用Driver#connect时出错 在org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator $ 1 $ 1.convert(BasicConnectionCreator.java:105) at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:123) 在org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:41) 在org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:58) 在org.hibernate.engine.jdbc.connections.internal.PooledConnections.addConnections(PooledConnections.java:123) 在org.hibernate.engine.jdbc.connections.internal.PooledConnections。(PooledConnections.java:42) 在org.hibernate.engine.jdbc.connections.internal.PooledConnections。(PooledConnections.java:20) 在org.hibernate.engine.jdbc.connections.internal.PooledConnections $ Builder.build(PooledConnections.java:161) 在org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:109) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:72) 在org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) 在org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) 在org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259) ......还有16个 引起:java.sql.SQLException:ORA-01017:用户名/密码无效;登录被拒绝