This is my class Main
Code:
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
public class Main {
public static void main(String[] arg) {
SessionFactory factory = new Configuration().configure().buildSessionFactory(); //error here
Session session = factory.openSession();
Transaction transaction = null;
try {
transaction = session.beginTransaction();
Person p1 = new Person();
p1.setPName("mike tyson");
session.save(p1);
transaction.commit();
transaction = null;
System.out.println("Thanh cong");
}
catch (Exception exp){
if ( transaction != null ){
transaction.rollback();
}
System.out.println("That bai");
}
finally {
session.close();
}
}
}
this is my file config:
Code:
<?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="connection.driver_class">org.apache.derby.jdbc.ClientDriver
</property>
<property name="connection.url">jdbc:derby://localhost:1527/mydatabase
</property>
<property name="connection.username">app
</property>
<property name="connection.password">app
</property>
<property name="dialect">org.hibernate.dialect.DerbyDialect
</property>
<mapping resource="Person.hbm.xml"/>
</session-factory>
</hibernate-configuration>
My application error at install FactorySession in class Main. I build it no problem but when i run project, it messenger error
Help me please !! Thank a lot of