问答详情
源自:1-11 通过Hibernate API编写访问数据库的代码

运行时出错。是不是hibernate.cfg.xml文件出错了啊?求指点

编译的结果:

一月 19, 2017 4:48:06 下午 org.hibernate.Version logVersion

INFO: HHH000412: Hibernate Core {5.2.6.Final}

一月 19, 2017 4:48:06 下午 org.hibernate.cfg.Environment <clinit>

INFO: HHH000206: hibernate.properties not found

一月 19, 2017 4:48:07 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>

INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}

一月 19, 2017 4:48:07 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)

一月 19, 2017 4:48:07 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001005: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:hibernate]

一月 19, 2017 4:48:07 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001001: Connection properties: {user=system, password=****}

一月 19, 2017 4:48:07 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001003: Autocommit mode: false

一月 19, 2017 4:48:07 下午 org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>

INFO: HHH000115: Hibernate connection pool size: 20 (min=1)


这是hibernate.cfg.xml文件

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

    <property name="connection.username">system</property>

    <property name="connection.password">huo123456</property>

    <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:hibernate</property>

    <property name="dialect">org.hibernate.dialect.Oracle11Dialect</property>

    

    <property name="show_sql">true</property>

    <property name="format_sql">true</property>

    <property name="hbm2ddl.auto">create</property>

    <mapping resource="Students.htm.xml"/>

    </session-factory>

</hibernate-configuration>


提问者:qq_火兹_03896205 2017-01-19 16:51

个回答

  • qq_火兹_03896205
    2017-01-21 15:23:22

    oracle11g,jar包是ojdbc6.jar,在目录文件中找到的,版本是匹配的,我另外单独创建了一个java工程,使用jdbc创建表格,增删改查功能都可以导入,所以我又怀疑是hibernatejar的问题。hibernate.cfg.xml这个文件没错吧?

  • 荣哥_仔
    2017-01-20 11:08:42

    首先你是的Oracle数据库的版本是多少,然后导入的Oracle驱动jar包版本是多少,可能是版本不匹配!