|
@@ -196,7 +196,7 @@ public class SqlTask extends AbstractTask {
|
|
|
}
|
|
|
|
|
|
// special characters need to be escaped, ${} needs to be escaped
|
|
|
- String rgex = "'?\\$\\{(.*?)\\}'?";
|
|
|
+ String rgex = "['\"]*\\$\\{(.*?)\\}['\"]*";
|
|
|
setSqlParamsMap(sql,rgex,sqlParamsMap,paramsMap);
|
|
|
|
|
|
// replace the ${} of the SQL statement with the Placeholder
|
|
@@ -310,6 +310,7 @@ public class SqlTask extends AbstractTask {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(),e);
|
|
|
+ throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
return connection;
|
|
|
}
|
|
@@ -326,6 +327,7 @@ public class SqlTask extends AbstractTask {
|
|
|
ParameterUtils.setInParameter(key,stmt,prop.getType(),prop.getValue());
|
|
|
}
|
|
|
}
|
|
|
+ logger.info("prepare statement replace sql:{}",stmt.toString());
|
|
|
return stmt;
|
|
|
}
|
|
|
|
|
@@ -371,9 +373,13 @@ public class SqlTask extends AbstractTask {
|
|
|
|
|
|
String showTypeName = sqlParameters.getShowType().replace(Constants.COMMA,"").trim();
|
|
|
if(EnumUtils.isValidEnum(ShowType.class,showTypeName)){
|
|
|
- MailUtils.sendMails(receviersList,receviersCcList,title, content, ShowType.valueOf(showTypeName));
|
|
|
+ Map<String, Object> mailResult = MailUtils.sendMails(receviersList, receviersCcList, title, content, ShowType.valueOf(showTypeName));
|
|
|
+ if(!(Boolean) mailResult.get(cn.escheduler.api.utils.Constants.STATUS)){
|
|
|
+ throw new RuntimeException("send mail failed!");
|
|
|
+ }
|
|
|
}else{
|
|
|
logger.error("showType: {} is not valid " ,showTypeName);
|
|
|
+ throw new RuntimeException(String.format("showType: %s is not valid ",showTypeName));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -411,19 +417,5 @@ public class SqlTask extends AbstractTask {
|
|
|
logPrint.append(sqlParamsMap.get(i).getValue()+"("+sqlParamsMap.get(i).getType()+")");
|
|
|
}
|
|
|
logger.info(logPrint.toString());
|
|
|
-
|
|
|
- //direct print style
|
|
|
- Pattern pattern = Pattern.compile(rgex);
|
|
|
- Matcher m = pattern.matcher(content);
|
|
|
- int index = 1;
|
|
|
- StringBuffer sb = new StringBuffer("replaced sql , direct:");
|
|
|
- while (m.find()) {
|
|
|
-
|
|
|
- m.appendReplacement(sb, sqlParamsMap.get(index).getValue());
|
|
|
-
|
|
|
- index ++;
|
|
|
- }
|
|
|
- m.appendTail(sb);
|
|
|
- logger.info(sb.toString());
|
|
|
}
|
|
|
}
|