使用 Hibernate 成功连接到 Oracle 只需 3 分钟
A successful connect to Oracle using Hibernate is 3 minutes
朋友说说三分钟工作Hibernate的原因
获取工厂的方法中:
sessionFactory = new Configuration().configure().buildSessionFactory();
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="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@<IP>:1521:sbboldev</property>
<property name="hibernate.connection.username">login</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">login</property>
<property name="show_sql">true</property>
<mapping resource="Developer.hbm.xml"/>
</session-factory>
</hibernate-configuration>
database_module.log
2019-02-08 12:06:08 DEBUG JdbcEnvironmentInitiator:72 - Database ->
name : Oracle
version : Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
major : 11
minor : 2
2019-02-08 12:06:08 DEBUG JdbcEnvironmentInitiator:83 - Driver ->
name : Oracle JDBC driver
version : 11.2.0.4.0
major : 11
minor : 2
2019-02-08 12:06:08 DEBUG JdbcEnvironmentInitiator:389 - JDBC version : 11.2
2019-02-08 12:06:08 INFO Dialect:158 - HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
2019-02-08 **12:06:08** DEBUG DefaultSchemaNameResolver:53 - Unable to use Java 1.7 Connection#getSchema
2019-02-08 **12:09:15** DEBUG Namespace:51 - Created database namespace [logicalName=Name{catalog=null, schema=null}, physicalName=Name{catalog=null, schema=null}]
2019-02-08 12:09:15 DEBUG ModelBinder:239 - Mapping class: net.proselyte.hibernate.example.Developer -> HIBERNATE_DEVELOPERS
Hibernate 核心版本:5.4.1.Final。
Java版本:1.8.0_161.
你能用最新的18.3 JDBC driver吗?
朋友说说三分钟工作Hibernate的原因
获取工厂的方法中:
sessionFactory = new Configuration().configure().buildSessionFactory();
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="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@<IP>:1521:sbboldev</property>
<property name="hibernate.connection.username">login</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">login</property>
<property name="show_sql">true</property>
<mapping resource="Developer.hbm.xml"/>
</session-factory>
</hibernate-configuration>
database_module.log
2019-02-08 12:06:08 DEBUG JdbcEnvironmentInitiator:72 - Database ->
name : Oracle
version : Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
major : 11
minor : 2
2019-02-08 12:06:08 DEBUG JdbcEnvironmentInitiator:83 - Driver ->
name : Oracle JDBC driver
version : 11.2.0.4.0
major : 11
minor : 2
2019-02-08 12:06:08 DEBUG JdbcEnvironmentInitiator:389 - JDBC version : 11.2
2019-02-08 12:06:08 INFO Dialect:158 - HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
2019-02-08 **12:06:08** DEBUG DefaultSchemaNameResolver:53 - Unable to use Java 1.7 Connection#getSchema
2019-02-08 **12:09:15** DEBUG Namespace:51 - Created database namespace [logicalName=Name{catalog=null, schema=null}, physicalName=Name{catalog=null, schema=null}]
2019-02-08 12:09:15 DEBUG ModelBinder:239 - Mapping class: net.proselyte.hibernate.example.Developer -> HIBERNATE_DEVELOPERS
Hibernate 核心版本:5.4.1.Final。 Java版本:1.8.0_161.
你能用最新的18.3 JDBC driver吗?