Close Menu
  • Home
  • Java
  • JavaScript
  • Hibernate
  • Deployment
  • Spring
Facebook X (Twitter) Instagram
Developers GroundDevelopers Ground
Facebook X (Twitter) Instagram
  • Home
  • Java
  • JavaScript
  • Hibernate
  • Deployment
  • Spring
Developers GroundDevelopers Ground
Home Hibernate Configuration File
Hibernate

Hibernate Configuration File

Akshay KulkarniBy Akshay KulkarniAugust 20, 2023Updated:August 20, 2023No Comments1 Min Read
Facebook Twitter Pinterest LinkedIn Tumblr Reddit WhatsApp Email
Share
Facebook Twitter LinkedIn Pinterest WhatsApp Email

What is the use of a Configuration file?

Ans:

  1. This file acts as a container for database-related information.
  2. Database name, driver name, URL, username, password, etc.
  3. We can add database-related information using <property> tag

What is the use of dialect property?

Ans:

  1. The dialect specifies the database used in hibernate application.
  2. By using this property, hibernate framework generates the appropriate SQL query based on the database vendor.
  3. Dialect property allows developers to connect hibernate applications with any database vendor.
<?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">
<!-- Version 8 MySQL hiberante-cfg.xml example for Hibernate 5 -->
<hibernate-configuration>
  <session-factory>
    <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
    <!-- For old version of MySQL -->
    <!-- property name="connection.driver_class">com.mysql.jdbc.Driver</property -->
    <property name="connection.url">jdbc:mysql://localhost:3306/demo</property>
    <property name="dialect">org.hibernate.dialect.MySQL8Dialect</property>
    <property name="connection.username">root</property>
    <property name="connection.password">password</property>
    <!--property name="dialect">org.hibernate.dialect.MySQLDialect</property-->
    <property name="show_sql">true</property>
    <property name="hbm2ddl.auto">update</property>
    <!-- add mapping resource / -->
    <mapping resource="mapping.hbm.xml" />
  </session-factory>
</hibernate-configuration>

 

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0
Akshay Kulkarni

Related Posts

Hibernate Primary Key Generation Strategies

March 26, 2023

What is Hibernate? Explain important features of Hibernate

March 20, 2023
Leave A Reply Cancel Reply

Featured Posts
  • 1
    Understanding the Java String Class
    • April 10, 2025
  • 2
    Array in Java
    • February 19, 2024
  • 3
    Control Statements
    • January 16, 2024
  • 4
    Java Objects
    • January 11, 2024
  • 5
    Java Constructors
    • January 2, 2024
Facebook X (Twitter) Instagram Pinterest
© 2025 Developers Ground, All rights reserved.

Type above and press Enter to search. Press Esc to cancel.