• Dear Guest, Please do NOT forget to join our JAVA JOBS (ONLY) FACEBOOK GROUP to be aware of latest JAVA openings, and you may also post any JAVA related queries/jobs.

How to run Hibernate program without Ant Tool and whether Eclipse/MyEclipse is compulsary for running Hibernate ?


I am new to hibernate.
I hv refered 1 site for hibernate intro.also hv read some programmes written in hibernate.
I want to know in depth abt hibernate.In that article I read how to run it using Ant.I want to know how to run it without Ant and whether Eclipse/MyEclipse is compulsary for running hibernate?
Thank you.
Without using ANt,Eclipse,we can run the hybernate.
If u have java in your pc,that is enough to run the hybernate.

sample code

import org.hibernate.cfg.Configuration;
import org.hibernate.SessionFactory;
import org.hibernate.Session;
import org.hibernate.Transaction;
import pack.Student;

class StudentDB
public static void main(String[] args)
SessionFactory sessionFactory;
Session ses;
sessionFactory = new Configuration().configure().buildSessionFactory();
Transaction tx=ses.beginTransaction();
Student inf=new Student();
System.out.println("Record Added");
}catch(Exception e){
System.out.println("The Exception is :"+e);


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

<class name="pack.Student" table="empdet">
<id name="id" column="ID" >
<generator class="increment"/>

<property name="name">
<column name="FIRSTNAME" />
<property name="email">
<column name="EMAIL"/>

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="connection.username">root</property>
<property name="connection.password">good</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<mapping resource="Student.hbm.xml"/>
Hello Mayuri,
yes u can write hibernnate program without using ANT.
U can use Eclipse ID or any other ID for better practice and run as java program.
u can run it using main method like simple java program