使用hracle与oracle的驱动程序连接问题

时间:2015-04-24 20:13:08

标签: java spring oracle hibernate netbeans

我使用hibernate时非常新,所以当我尝试连接到Oracle数据库时,我遇到了问题。我正在按照一步一步this教程,但Creating the Hibernate Reverse Engineering File here我在oracle驱动程序尝试建立连接时遇到了一些错误。这是确切的错误:

enter image description here

这是我的hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
    <property name="hibernate.connection.username">hotel</property>
    <property name="hibernate.connection.password">hotel</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
  </session-factory>
</hibernate-configuration>

也许我需要在某处设置jdbc oracle驱动程序,但我不确切知道在哪里。知道什么可能是错的吗?

提前致谢!!

1 个答案:

答案 0 :(得分:1)

Oracle驱动程序不在您的类路径中。您需要转到Oracle站点并下载Oracle瘦驱动程序。这是11g的页面:

http://www.oracle.com/technetwork/apps-tech/jdbc-112010-090769.html

以下是与oracle交谈的netbeans说明:

https://netbeans.org/kb/docs/ide/oracle-db.html#oci

您必须先安装Oracle Database Instant Client,然后确保ojdbc6.jar文件位于类路径中。