public boolean isAuditTrailEnabled(String masterAccessId)
{
String selectQuery = "select t.audit_flag from PARAMETER_MENU_ATTRIBUTES t where t.access_id = '"+masterAccessId+"'";
PreparedStatement preparedStmnt = null;
ResultSet resultSet = null;
String flag = "N";
if(connection == null)
{
initConnection();
}
try {
**preparedStmnt = connection.prepareStatement(selectQuery);**
resultSet = preparedStmnt.executeQuery();
if(resultSet.next())
{
flag = resultSet.getString(1);
}
}
catch (SQLException e) {
try {
if (resultSet != null){
resultSet.close();
}
if (preparedStmnt != null){
preparedStmnt.close();
}
} catch (SQLException e1) {
}
return true;
}
finally{
try {
if (resultSet != null){
resultSet.close();
}
if (preparedStmnt != null){
preparedStmnt.close();
}
cleanup();
} catch (SQLException e1) {
return false;
}
}
if(flag.equals("N")){
return false;
}else{
return true;
}
}
它显示了该特定声明中的问题。你能帮我吗?
答案 0 :(得分:0)
总是结果集和语句应该在单独的try catch中关闭...如果不能以这种方式编写,甚至是2 ...要么它应该首先循环,如果...或者保留其他如果... ..如果条件优先,通过基础
if(something)
{
if(something)
}
or
if((something) &&(something))