方法1:
public String getSomeThingInfo(String A,
String B)throws SystemException,
SQLException {
String str = "";
selectDBForRsInfo("select XXX from table where zhujian = ? ", new Object[] {?dezhi});
if (rs.next()) {
str = rs.getString("XXX");
}
return str;
}
方法2:
public String getSomeThingInfo(String A,
String B)
throws SystemException,
SQLException {
String str = "";
try {
ResultSet rs =
selectDBForRsInfo("select XXX from table where zhujian = ? ", new Object[] {?dezhi});
if (rs.next()) {
str = rs.getString("XXX");
}
} catch (Exception e) {
// エラーが発生しました。
throw new Exception(errorMessage, e);
}
return str;
}
方法1和方法2抛出异常的方法不同,如果不知道errorID的情况下可以向方法1一样直接把异常throw出去,
如果知道要抛出的errorID的情况下可以向方法2一样利用try{}catch{throw。。。} 因为用了throw 所以又回滚操作,如果不用throw,则没有回滚操作。