/**
* 查询用户角色表 roleuser
* 根据据userNo
* 查出对应的部门代码集合
*/
public static List getDepCodeList(String userNo){
TSGRoleuserDao roleuserDao= (TSGRoleuserDao)BeanContext.getBean("daoTSGRoleuser");
Map map=new HashMap();
map.put("userNo", userNo);
map.put("roleuserStatus",TSGConstants.TSG_enables_undel);
List list=roleuserDao.query(map);
List depCodelist=new ArrayList();
try {
if(list.size()>0&&list!=null){
for (int i = 0; i <list.size(); i++) {
list.add(i, ((Map)list.get(i)).get("ROLE_CODE").toString());
}
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return depCodelist.size()>0&&depCodelist!=null?depCodelist:null;
}try{
}catch(Exception e){
}finally{
}用有什么好处?不用有什么坏处?到底什么时候用才最合适呢?大家都来吼吼吧!
* 查询用户角色表 roleuser
* 根据据userNo
* 查出对应的部门代码集合
*/
public static List getDepCodeList(String userNo){
TSGRoleuserDao roleuserDao= (TSGRoleuserDao)BeanContext.getBean("daoTSGRoleuser");
Map map=new HashMap();
map.put("userNo", userNo);
map.put("roleuserStatus",TSGConstants.TSG_enables_undel);
List list=roleuserDao.query(map);
List depCodelist=new ArrayList();
try {
if(list.size()>0&&list!=null){
for (int i = 0; i <list.size(); i++) {
list.add(i, ((Map)list.get(i)).get("ROLE_CODE").toString());
}
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return depCodelist.size()>0&&depCodelist!=null?depCodelist:null;
}try{
}catch(Exception e){
}finally{
}用有什么好处?不用有什么坏处?到底什么时候用才最合适呢?大家都来吼吼吧!
}catch(Exception e){
}要怎么用就不用说了嘛,就是捕获异常,处理异常,finally一般在你需要关闭数据库连接,关闭文件连接的时候需要用到,当然其他地方可能用到,我就说了常用的
* 查询用户角色表 roleuser
* 根据据userNo
* 查出对应的部门代码集合
*/
public static List getDepCodeList(String userNo){
List depCodelist=new ArrayList();
String msg=null;
try {
TSGRoleuserDao roleuserDao= (TSGRoleuserDao)BeanContext.getBean("daoTSGRoleuser");
Map map=new HashMap();
map.put("userNo", userNo);
map.put("roleuserStatus",TSGConstants.TSG_enables_undel);
List list=roleuserDao.query(map); if(list.size()>0&&list!=null){
for (int i = 0; i <list.size(); i++) {
list.add(i, ((Map)list.get(i)).get("ROLE_CODE").toString());
}
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
msg=e.getMessage();
}finally{
if(msg==null){
return depCodelist.size()>0&&depCodelist!=null
}else{
return null;//报错处理
}
}
}
//代码编译块,代码出现异常,结束下面的代码编译,执行catch块
}catch(Exception e){
//代码块的异常处理,接受代码编译的异常,没异常不执行
}finally{
//不管有不有异常,都会执行
}
一般catch都定义很多块如try{
}catch(NullPointException ne){
}catch(ClassNotFoundException cnfe){
}catch(ClassCastException cce){
}finally{
}
等 把每个可能出现的异常监听
finally我一般是用来关闭数据库连接的
一般try...catch..finally属于一般异常,通常用于易出现错误的如HibernateError,ThrowableException,IOException,SqlException等等;