HELLO FRIENDS...CLICK ON SEE MORE TO VIEW ALL QUES..
DON'T FORGET TO LIKE...........
like page -get daily updates
DON'T FORGET TO LIKE...........
like page -get daily updates
Post by Java Code Helps.
Post by Java Code Helps.
Post by Java Code Helps.
hello,
ReplyDeletethis is my code to add a user but it didn't work :
public void CreateUser(UserBean u) {
Transaction trs = null;
Session session = HibernateUtil.getSessionFactory().openSession();
try {
session.beginTransaction();
session.save(u);
session.getTransaction().commit();
}
catch (RuntimeException e) {
if (trs!=null)
{ try {
trs.rollback();
} catch (IllegalStateException ex) {
Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
} catch (SystemException ex) {
Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
}
e.printStackTrace();
}
}
finally {
session.close();
HibernateUtil.getSessionFactory().close();
}
}
public void saveUser()
{
User u = new User();
u.CreateUser(this);
clearAll();
}
public void UpdateUser(UserBean u) {
Transaction trs = null;
Session session = HibernateUtil.getSessionFactory().openSession();
try {
session.beginTransaction();
session.save(u);
session.getTransaction().commit();
}
catch (RuntimeException e) {
if (trs!=null)
{ try {
trs.rollback();
} catch (IllegalStateException ex) {
Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
} catch (SystemException ex) {
Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
}
e.printStackTrace();
}
}
finally {
session.close();
HibernateUtil.getSessionFactory().close();
}
}
public void saveUpdatedUser()
{
User u = new User();
u.UpdateUser(this);
clearAll();
}