In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how datax-web ExecutorJobHandler modifies the source code to solve the sqlserver time format does not recognize the% of the time string, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Question:
Select * from dbo.SKJJGWFGXX where (i_time > = '1980-01-01-01-01-01-01-01-01-01-01-01-01-01-01-0000' and i_time
< '2020-12-15:25:40') 具体错误信息为:com.microsoft.sqlserver.jdbc.SQLServerException: 从字符串转换日期和/或时间时,转换失败。 时间字符串中带%,mysql数据库能识别并正确执行,而sqlserver数据库(2008)不能识别,造成查询失败。 如果此问题不解决,那么从sqlserver到mysql的数据同步中,无法采用时间增量方式进行数据实时同步。 在java中和python中都尝试把"%"换成空格,最后的结果都是无法运行。估计是在命令行中做为参数传入时,空格本身是特殊符号,用于分开命令和参数的,强行替换,最后导致时间字符串被分成两段接收。 解决方案: 修改ExecutorJobHandler,生成job临时文件时,把临时文件中的变量用具体值进行替换。A new processing method: replaceJobJsonParams is defined.
/ / zhuangxl 2020.12.15 replacement begins
String jobJson = new String (trigger.getJobJson ())
JobJson = replaceJobJsonParams (jobJson, trigger)
TmpFilePath = generateTemJsonFile (jobJson)
/ / zhuangxl 2020.12.15 replacement ends
/ * *
* replace job file parameters
* @ author zhuangxl
* @ param jobJson
* @ return
, /
Private String replaceJobJsonParams (String jobJson, TriggerParam trigger) {
If (IncrementTypeEnum.TIME.getCode () = = trigger.getIncrementType ()) {
String replaceParamType = trigger.getReplaceParamType ()
/ / Category: time increases by itself, and only operates types that specify a specific time format.
If (StringUtils.isNotBlank (replaceParamType) & &! replaceParamType.equals ("Timestamp")) {
/ / format the time string
SimpleDateFormat sdf = new SimpleDateFormat (replaceParamType)
String endTime_ = sdf.format (trigger.getTriggerTime ())
String startTime_ = sdf.format (trigger.getStartTime ())
/ / identify the name of the time variable to be replaced
String [] replaceParams = trigger.getReplaceParam () .split ("")
String startTimeStr = replaceParams [0] .substring (replaceParams [0] .indexOf ("D") + 1, replaceParams [0] .indexOf ("="))
String endTimeStr = replaceParams [1] .substring (replaceParams [1] .indexOf ("D") + 1, replaceParams [1] .indexOf ("="))
/ / perform variable substitution
JobJson = jobJson.replace ("${" + startTimeStr+ "}", "'" + startTime_+ "'")
JobJson = jobJson.replace ("${" + endTimeStr+ "}", "'" + endTime_+ "'")
}
}
Return jobJson
}
After reading the above, do you have any further understanding of how datax-web ExecutorJobHandler modifies the source code to solve the problem that the sqlserver time format does not recognize% of the time string? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.