Hibernate Configuration by R4R Team

Hibernate has to set of configuration settings related to database and other related parameters. All such information is usually supplied as a standard Java properties file called hibernate.properties, or as an XML file named hibernate.cfg.xml. That will consider XML formatted file hibernate.cfg.xml to specify required Hibernate properties . Most of the properties take their default values and it is not required to specify them in the property file unless it is really required. This file is kept in the root directory of your application's classpath.

Hibernate Properties

Following is the list of important properties would require to configure for a databases in a standalone situation:

Properties

                             Description

 

 hibernate.dialect

 

This property makes Hibernate generate the appropriate SQL for the chosen database.

hibernate.connection.driver_class

The JDBC driver class.

 hibernate.connection.url

The JDBC URL to the database instance.

 hibernate.connection.username

The database username.

 hibernate.connection.password

The database password

hibernate.connection.pool_size

Limits the number of connections waiting in the Hibernate database connection pool.

hibernate.connection.autocommit

Allows autocommit mode to be used for the JDBC connection.


When we use a database along with an application server and JNDI then we need to configure the following properties:

Properties

Description

 

hibernate.connection.datasource

The JNDI name defined in the application server context you are using for the application.

hibernate.jndi.class

The InitialContext class for JNDI.

hibernate.jndi.

Passes any JNDI property you like to the JNDI InitialContext

hibernate.jndi.url

Provides the URL for JNDI.

hibernate.connection.username

The database username.

hibernate.connection.password

The database password

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!