Topic: 异常处理

  Print this page

1.异常处理 Copy to clipboard
Posted by: frog2004
Posted on: 2005-08-02 14:21

比较两个异常处理办法:
[A]:
try{
//数据库异常错误
}
catch(SQLException e){
//数据库回滚
//抛出异常
}

[B]:
try{
//数据库异常错误
}
catch(SQLException e){
//数据库回滚
flg = true;//设置标志
}
if(flg){
//结束程序
}

A,B两中方法哪种好些?从JAVA思想上来看,有什么异同吗?高手来指点看看!!!

2.Re:异常处理 [Re: frog2004] Copy to clipboard
Posted by: ranchgirl
Posted on: 2005-08-02 22:07


try{
//数据库异常错误
}
catch(SQLException e){
//数据库回滚
// handle the exception properly
// give user error msg
// finish application gracefully, if that is your intention. Don't do this if not necessary
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923