Did you have created a hibernate.properties or hibernate.cfg.xml file? If not, create hibernate.properties with the following properties:
Code:
hibernate.connection.driver_class=my.driver.Class
hibernate.connection.url=my://url
hibernate.connection.username=user
hibernate.connection.password=pass
hibernate.dialect=dialect.for.Database
# use it instead Environment.HBM2DDL_AUTO, "create"
hibernate.hbm2ddl.auto=create
Course, put properties' values appropriated for your database. Later, change your code to:
Code:
try {
Configuration configuration = new Configuration();
// loading you properties file
configuration.configure("dir/hibernate.properties")
SessionFactory sf = configuration.buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
for (int i = 0; i < 200; i++) {
Customer customer = new Customer();
customer.setUsername("customer" + i);
customer.setPassword("customer");
session.save(customer);
}
tx.commit();
}
ps.:Please, use code tags when posting java coding or mappings.
Kind Regards