异常处理的问题
写了这样一个函数
public Object executeSingleQuery(String strPoolName,String sqlString)
{
Statement stmt = null;
ResultSet rs = null;
Object returnObject = null;
Connection conn = null;
try{
conn = getConnection(strPoolName);
stmt = conn.createStatement();
rs = stmt.executeQuery(sqlString);
if(rs.next()){
returnObject = rs.getObject(1);
}
rs.close();
stmt.close();
conn.commit();
freeConnection(strPoolName,conn);
}catch (SQLException e){
log(e.toString()+",执行查询语句失败");
rs.close();
stmt.close();
freeConnection(strPoolName,conn);
throw e;
}
return returnObject;
}
提示throw e这行有错,错误提示为
Error #: 360 : unreported exception: java.sql.SQLException; must be caught or declared to be thrown at line 235, column 5
我觉得没有错啊,为什么?当把catch里的
rs.close();
stmt.close();
throw e;
去掉则正常了,但这不符合要求啊,请高手帮忙哦!