Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Hibernate Hibernate4 Hibernate db2

Related Tutorials


 
 

Share on Google+Share on Google+

Hibernate db2

Advertisement
In this section, you will learn about the db2 configuration in Hibernate.

Hibernate db2

In this section, you will learn about the db2 configuration in Hibernate.

Since Hibernate is independent of database, if you are using db2, then you need to change the hibernate.cfg.xml .

The hibernate.cfg.xml configuration file for the db2 is given below :

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
<property name="connection.url">jdbc:db2://192.168.10.13:3306/anky</property>
<property name="connection.username">user</property>
<property name="connection.password">pass</property>

<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="show_sql">true</property>

<mapping class="net.roseindia.Student" />
<mapping class="net.roseindia.Course" />

</session-factory>
</hibernate-configuration>

The description of the tags of the above configuration file is given below :

  • connection.driver_class : This property element is used to provide the name of the driver class.
  • connection.url : This property element is used to provide the URL for the database connection.
  • connection.username : This property element is used to provide the username by which you are logging to the database.
  • connection.password : This property element is used to provide the password by which you are logging to the database.
  • connection.pool_size : This property element configures the number of connections of connection pool of the built-in Hibernate.
  • dialect : This property defines the particular SQL variant with which the Hibernate will carry on a conversation. Use of this property is necessary when there are multiple databases are targeted by an application.

At last of you will be required to map the persistent class(POJO) file to the configuration.



Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 17, 2012

Related Tutorials

Discuss: Hibernate db2  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com