Hibernate java.lang.ClassCastException: oracle.jdbc.driver.OracleDriver cannot be cast to org.hibernate.engine.jdbc.connections.spi.ConnectionProvider

org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:261)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
    at com.zhaogd.myapplication.test.Test.main(Test.java:30)
Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [oracle.jdbc.driver.OracleDriver]
    at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:197)
    at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:120)
    at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:55)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
    ... 10 more
Caused by: java.lang.ClassCastException: oracle.jdbc.driver.OracleDriver cannot be cast to org.hibernate.engine.jdbc.connections.spi.ConnectionProvider
    at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:194)
    ... 14 more

今天使用Hibernate 搞了好半天没有搞好,网上搜索这个问题可能是问题太低级了没有搜到 认真比较原来是Hibernate配置文件中<property name="connection.provider_class">oracle.jdbc.driver.OracleDriver</property>写错了 应该是

<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 导致orcale中的驱动包ojdbc6.jar,Hibernate没有加载。

 

hibernate.cfg.xml中的configure模式

posted @ 2016-02-24 21:58  点点滴滴,成就未来!  阅读(1586)  评论(0编辑  收藏  举报