Home Hibernate Hibernate Getting Started



Hibernate Getting Started
Posted on: October 20, 2010 at 12:00 AM
In this Hibernate Getting Started you will quickly download the a Hibernate running example project and run on your machine.

Hibernate Getting Started

     

Hibernate Getting Started

In this Hibernate Getting Started you will quickly download the a Hibernate running example project and run on your machine.

After completing this tutorial you should be able to run the hibernate based application from Eclipse Environent.

Let's get started with the fast track Hibernate Getting Started tutorial.

What is required?

  • I am assuming that Java is installed and configured on your computer.
  • MySQL database is installed on your computer.
  • Latest version of Eclipse is installed and configured on your computer.

Downloading the project

Download the Hibernate Getting Started project. Save the file into hard disk and extract.

Opening the project in Eclipse:

Open eclipse and select File --> New --> Java Project. This will open the wizard as shown below:



Now Select "Create project from existing source" and enter the path where you have extracted the code. In My case it is C:\copyhere\hibernategettingstarted\HibernateGettingStarted. As shown below:


Now Click on the Finish button.

Your project is ready.

Create database
I am assuming that MySQL is installed on the local host. Create new database using following command:

create database hibernatetutorial;

Open hibernate.cfg.xml file and change the database access username and password if it is different.

<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernatetutorial</property>

<property name="hibernate.connection.username">root</property>

<property name="hibernate.connection.password">root</property>


Now everything is set and you can run the example code.

Running the Example

Open FirstExample.java in eclipse IDE and then run as shown below:


In the Eclipse console you will find the following output:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).

log4j:WARN Please initialize the log4j system properly.

Inserting Record

Done

Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?)

 

In this short tutorial we learned how to run the Hibernate application from Eclipse IDE. You can continue learning hibernate tutorial at http://www.roseindia.net/hibernate.

Related Tags for Hibernate Getting Started:


More Tutorials from this section

Ask Questions?    Discuss: Hibernate Getting Started  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.