Thursday, July 16, 2015

What is Hibernate.cfg.xml?

Why do we need Hibernate.cfg.xml and what is the importance of it?
Hibernate is designed in such way that it works on varius configurational parameters. There are various configurational parameters available in the Hibernate library so you have to use it according to your need.
Now for our ease Hibernate has provided us an XML file in which we can configure our database settings so that hibernate will read our database settings and than it will establish the connections with the our Database. So what are those configurational parameters ?
  • hibernate.connection.driver_class : - It is the JDBC Class name of driver which depends on the what kind of database you are using like for MYSQL – com.mysql.jdbc.Driver , ORACLE – oracle.jdbc.driver.OracleDriver
  • hibernate.connection.url : – It is the JDBC URL through which hibernate will establish the connection with your database
  • hibernate.connection.username : – It is the Username of Database Schema user.
  • hibernate.connection.password : – It is the Password of Database Schema user
  • dialect : - It is way to tell Hibernate which SQL language it should use to talk to database.
  • connection.pool_size : – It is used to limit the number of connections waiting in Hibernate Connection Pool
  • current_session_context_class : – It is used to enable Hibernate's automatic session context management
  • show_sql : – If you want to print the HQL (Hibernate query Language) in the form SQL in the logs than set the value of this flag to true
Types of Dialect : -
Database Dialect Property
DB2 org.hibernate.dialect.DB2Dialect
HSQLDB org.hibernate.dialect.HSQLDialect
HypersonicSQL org.hibernate.dialect.HSQLDialect
Informix org.hibernate.dialect.InformixDialect
Ingres org.hibernate.dialect.IngresDialect
Interbase org.hibernate.dialect.InterbaseDialect
Microsoft SQL Server 2000 org.hibernate.dialect.SQLServerDialect
Microsoft SQL Server 2005 org.hibernate.dialect.SQLServer2005Dialect
Microsoft SQL Server 2008 org.hibernate.dialect.SQLServer2008Dialect
MySQL org.hibernate.dialect.MySQLDialect
Oracle (any version) org.hibernate.dialect.OracleDialect
Oracle 11g org.hibernate.dialect.Oracle10gDialect
Oracle 10g org.hibernate.dialect.Oracle10gDialect
Oracle 9i org.hibernate.dialect.Oracle9iDialect
PostgreSQL org.hibernate.dialect.PostgreSQLDialect
Progress org.hibernate.dialect.ProgressDialect
SAP DB org.hibernate.dialect.SAPDBDialect
Sybase org.hibernate.dialect.SybaseDialect
Sybase Anywhere org.hibernate.dialect.SybaseAnywhereDialect
GoTo following Link for more information on various configuration parameters of Hibernate : -
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html

No comments:

Post a Comment