A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Hibernate with MySQL Database:

Hibernate with MySQL Database:

MySQL is one of the most popular open-source database systems available today. Let us create hibernate.cfg.xml configuration file and place it in the root of your application's classpath. You would have to make sure that you have testdb database available in your MySQL database and you have a user test available to access the database.
The XML configuration file must conform to the Hibernate 3 Configuration DTD, which is available from http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM

   <property name="hibernate.dialect">
   <property name="hibernate.connection.driver_class">

   <!-- Assume test is the database name -->
   <property name="hibernate.connection.url">
   <property name="hibernate.connection.username">
   <property name="hibernate.connection.password">

   <!-- List of XML mapping files -->
   <mapping resource="Employee.hbm.xml"/>


The above configuration file includes <mapping> tags which are related to hibernate-mapping file and we will see in next chapter what exactly is a hibernate mapping file and how and why do we use it.