Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. @Entity
  2. public class userDetails {
  3. @Id
  4. private int userId;
  5. private String userName;
  6. //setters and getters
  7. }
  8.  
  9. package firstHibernateproj;
  10.  
  11. import org.hibernate.Session;
  12. import org.hibernate.SessionFactory;
  13. import org.hibernate.cfg.Configuration;
  14.  
  15. public class hibernateclass {
  16. public static void main(String[] args) {
  17. userDetails user=new userDetails();
  18. user.setUserId(1);
  19. user.setUserName("madhu");
  20. SessionFactory sessionfactory=new Configuration().configure().buildSessionFactory();
  21. Session session=sessionfactory.openSession();
  22. session.beginTransaction();
  23. session.save(user);
  24. session.getTransaction().commit();
  25. }
  26.  
  27. }
  28.  
  29. Exception in thread "main" org.hibernate.QueryTimeoutException: Cannot open connection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement