// This step will read hibernate.cfg.xml System.out.println("hi---2"); //and prepare hibernate for use File file = new File("D:\\denaveworkspace\\workspace2\\HibernateProject\\bin\\hibernate.cfg.xml"); //Configuration cfg = new Configuration(); //cfg.addFile("/bin/hibernate.cfg.xml");
System.out.println("hi---3"); //Create new instance of Contact and set
//values in it by reading them from form object System.out.println("Inserting Record"); UserInfos user = new UserInfos(); user.setId("Nawi"); user.setUserName("nawi"); user.setPassword("nawi");
session.save(user); System.out.println("Done"); tx.commit(); }catch(Exception e){ e.printStackTrace(); }finally{ // Actual contact insertion will happen at this step session.flush(); session.close();