In this post, we are going to discus about how prepare the hibernate configuration file and what is the purpose of this file.
The hibernate framework requires this, because, hibernate needs to know which database system is communicate at run time to perform persistence operations.
In hibernate.cfg.xml, we configure all data base related information to hibernate by using some hibernate properties. we discuss later about these all properties which supported in configuration file. Now we discuss some properties which requires by our application.
Properties:
hibernate.connection.driver_class: It specifies the name of the database Driver Class.
hibernate.connection.url: It specifies the database URL connection.
hibernate.connection.username:It specifies the database username.
hibernate.connection.password: It represents database user account password.
dialect: dialect is used to provide database related information to hibernate system for generating SQL queries to specific database.
show_sql: This property is used to set true when we require to show sql query in console at time of application execution
The following screen shot explains all the above properties and how to configure in configuration file.
Note:
1.The above properties is also used without specifying hibernate.
ex: hibernate.connection.driver_class and connection.driver_class both is used alternatively.
2. We copy the hibernate.cfg.xml from hibernate distribution file. You just copy the both hibernate.cfg.xm and log4j.properties file fromhibernate-distribution file and copy into the Our application root folder.
Location:
D:\softwares-hibernate\hibernate-distribution-3.3.2.GA-dist\hibernate-distribution-3.3.2.GA\project\tutorials\web\src\main\resources
0 comments :
Post a Comment