The Hibernate configuration file connecting to the Oracle database has two formats: xml format and Java attribute file format.
The Hibernate configuration file connecting to the Oracle database has two formats: xml format and Java attribute file format.
Connect to the Hibernate configuration file of the Oracle database
The Hibernate configuration file connected to Oracle has two formats: xml and Java attribute file. The codes of the configuration files in these two formats are given below.
1. configuration file in xml format
The following provides the Hibernate configuration file hibernate. cfg. xml code for connecting to the db_database02 database on the local Oracle server.
Example 2-5: CD \ mr \ 02 \ sl \ 05 \ hibernate. cfg. xml
PUBLIC "-// Hibernate/Hibernate Configuration DTD // EN"
Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd>
Oracle. jdbc. driver. OracleDriver
Jdbc: oracle: thin: @ localhost: 1521: db_database02
SYSTEM
SYSTEM
Org. hibernate. dialect. Oracle9Dialect
True
In the code above, "localhost" indicates the local Oracle server. To connect to other servers, you can change it to the name of the Oracle server to be connected; "db_database02" indicates the name of the database to be connected; "SYSTEM" indicates the logon user name; "SYSTEM" indicates the user password; "UserForm. hbm. xml is the name of the ing file corresponding to the persistence class.
2. configuration file in Java attribute File Format
The Hibernate configuration file hibernate. properties code for connecting to the db_database02 database on the local Oracle server is provided below.
Example 2-6: CD \ mr \ 02 \ sl \ 06 \ hibernate. properties
# Specify the SQL dialect used to connect to the database #
Hibernate. dialect = org. hibernate. dialect. MySQLDialect
# Specify the driver used to connect to the database #
Hibernate. connection. driver_class = oracle. jdbc. driver. OracleDriver
# Specify the URL to connect to the database #
Hibernate. connection. url = jdbc: oracle: thin: @ localhost: 1521: db_database02
# Specify the username used to connect to the database #
Hibernate. connection. username = SYSTEM
# Specify the database connection password #
Hibernate. connection. password = SYSTEM
# Specify whether to output SQL statements on the console during program execution #
Hibernate. show_ SQL = true
In the code above, "localhost" indicates the local Oracle server. To connect to other servers, you can change it to the name of the Oracle server to be connected; "db_database02" indicates the name of the database to be connected; "SYSTEM" indicates the logon user name, and "SYSTEM" indicates the user password.
Note: A Hibernate. properties file is attached to the etc directory of the hibernate package to connect to various Relational Database Configuration codes. You can write the configuration file for connecting to other databases based on this file.
,