//this is bean class
package com;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="Student")
public class Bean_class implements Serializable {
public Bean_class() {
}
@Id
@Column(name = "id")
Integer id;
@Column(name = "name")
String name;
@Column(name="address")
String add;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAdd() {
return add;
}
public void setAdd(String add) {
this.add = add;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
This is program for inserting values in table
package com;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class Inserting_values {
public static void main(String areg[]) {
Session session = null;
try {
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
System.out.println("Entering Data");
Transaction tx = session.beginTransaction();
Bean_class bean_class = new Bean_class();
bean_class.setId(411);
bean_class.setName("Pathya");
bean_class.setAdd("cbd");
session.save(bean_class);
tx.commit();
System.out.println("Done");
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
// Actual contact insertion will happen at this step
// session.flush();
session.close();
}
}
}
this is config file
<?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>
<property name="hibernate.dialect">org.hibernate.dialect.Der byDialect</property>
<property name="hibernate.connection.driver_class">org.apach e.derby.jdbc.ClientDriver</property>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/Empl</property>
<property name="hibernate.hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>
When i am executing this the table is not creating in derby database of netbeans 7.2