public boolean inserinfo(Students stu)
{
try
{
this.session =HibernateSessionFactory.getSession();
this.tr=this.session.beginTransaction();
this.session.save(stu);
this.tr.commit();//执行了这一句肯定成功,返回True;
return true;
}
catch(Exception e)
{
return false;//抛出异常,返回False;
throw e;
}finally
{
if(this.session.Isopen)
{
this.session.close();//关闭Session;
}
}
}
Hibernate好用
搞个异常处理。未抛出异常就算成功
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....