Browse Source

for bug #1379. (#1439)

Now all datatype use same method ` stmt.setString(index,value);` even DATE and TIMESTAMP.

So i had improved it. If datatype is DATE use `stmt.setDate(index, java.sql.Date.valueOf(value));` , if datatype is TIMESTAMP use `stmt.setTimestamp(index, java.sql.Timestamp.valueOf(value));`.i

When use DATE the param format must use $[yyyy-MM-dd] , When use TIMESTAMP the param format must use $[yyyy-MM-dd hh:mm:ss].
pull/2/head
zhukai 5 years ago committed by qiaozhanwei
parent
commit
5cecc0e618
  1. 4
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
  2. 2
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java

4
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java

@ -98,11 +98,11 @@ public class ParameterUtils {
}else if (dataType.equals(DataType.DOUBLE)){
stmt.setDouble(index, Double.parseDouble(value));
}else if (dataType.equals(DataType.DATE)){
stmt.setString(index, value);
stmt.setDate(index, java.sql.Date.valueOf(value));
}else if (dataType.equals(DataType.TIME)){
stmt.setString(index, value);
}else if (dataType.equals(DataType.TIMESTAMP)){
stmt.setString(index, value);
stmt.setTimestamp(index, java.sql.Timestamp.valueOf(value));
}else if (dataType.equals(DataType.BOOLEAN)){
stmt.setBoolean(index,Boolean.parseBoolean(value));
}

2
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java

@ -211,7 +211,7 @@ public class SqlTask extends AbstractTask {
if (StringUtils.isNotEmpty(sqlParameters.getTitle())){
String title = ParameterUtils.convertParameterPlaceholders(sqlParameters.getTitle(),
ParamUtils.convert(paramsMap));
logger.info("SQL tile : {}",title);
logger.info("SQL title : {}",title);
sqlParameters.setTitle(title);
}

Loading…
Cancel
Save