Connect to the Hibernate configuration file of the Oracle database

Source: Internet
Author: User
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.

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.