025-03-16 21:26:18.516 [main] WARN Engine - prioriy set to 0, because NumberFormatException, the value is: null 2025-03-16 21:26:18.517 [main] INFO PerfTrace - PerfTrace traceId=job_-1, isEnable=false, priority=0 2025-03-16 21:26:18.517 [main] INFO JobContainer - DataX jobContainer starts job. 2025-03-16 21:26:18.519 [main] INFO JobContainer - Set jobId = 0 Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The dr iver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.2025-03-16 21:26:18.885 [job-0] INFO OriginalConfPretreatmentUtil - Available jdbcUrl:jdbc:mysql://master:3306/szt?y earIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true.2025-03-16 21:26:18.913 [job-0] INFO OriginalConfPretreatmentUtil - table:[szt_data] has columns:[car_no,card_no,clo se_date,company_name,conn_mark,deal_date,deal_money,deal_type,deal_value,equ_no,station].三月 16, 2025 9:26:19 下午 org.apache.hadoop.util.NativeCodeLoader <clinit> 警告: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 2025-03-16 21:26:19.553 [job-0] INFO JobContainer - jobContainer starts to do prepare ... 2025-03-16 21:26:19.553 [job-0] INFO JobContainer - DataX Reader.Job [mysqlreader] do prepare work . 2025-03-16 21:26:19.554 [job-0] INFO JobContainer - DataX Writer.Job [hdfswriter] do prepare work . 2025-03-16 21:26:19.623 [job-0] INFO HdfsWriter$Job - 由于您配置了writeMode append, 写入前不做清理工作, [/daas/ods/o ds_szt_data] 目录下写入相应文件名前缀 [part] 的文件2025-03-16 21:26:19.623 [job-0] INFO JobContainer - jobContainer starts to do split ... 2025-03-16 21:26:19.623 [job-0] INFO JobContainer - Job set Channel-Number to 2 channels. 2025-03-16 21:26:19.646 [job-0] INFO SingleTableSplitUtil - split pk [sql=SELECT MIN(equ_no),MAX(equ_no) FROM szt_da ta WHERE (date_format(deal_date,'%Y%m%d') ='${dt}' AND equ_no IS NOT
时间: 2025-03-16 20:13:59 浏览: 33
### DataX中NumberFormatExeption问题分析
在DataX运行过程中遇到`java.lang.NumberFormatException`异常通常是因为数据转换失败引起的。此错误可能发生在读取MySQL数据并写入HDFS的过程中,具体原因可能是字段类型不匹配或者配置文件中的参数设置有误。
#### 可能的原因及解决方案:
1. **字段类型不一致**
如果从`mysqlreader`读取的数据中有字符串类型的数值(如`'123'`),而目标表期望的是整数或其他数值型,则可能会抛出`NumberFormatException`。因此,在插件配置阶段需确认字段映射关系是否正确[^1]。
2. **JDBC URL 配置不当**
`jdbcUrl`应指向有效的MySQL实例地址,并且需要指定正确的驱动类名`com.mysql.cj.jdbc.Driver`来加载对应的MySQL JDBC驱动程序。如果使用的驱动版本与实际数据库环境不符也可能引发各种兼容性问题。
3. **Hadoop Native Library 缺失或未启用**
当使用`hdfswriter`时,某些操作依赖于本地库的支持。如果没有正确安装或启用了Hadoop的native libraries,这可能导致性能下降甚至功能失效。可以通过设置环境变量`HADOOP_OPTS="-Djava.library.path=/path/to/hadoop/lib/native"`来解决这个问题[^2]。
4. **Write Mode 设置为 Append 的影响**
对于`writeMode=append`的情况,意味着每次执行都会向已有文件追加新记录而不是覆盖它们。这种模式下需要注意重复键处理逻辑以及最终一致性保障机制的设计。
以下是基于上述讨论的一个典型配置片段示例:
```json
{
"job": {
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"username": "your_username",
"password": "your_password",
"column": ["id", "value"],
"connection": [{
"jdbcUrl": ["jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false"],
"table": ["test_table"]
}]
}
},
"writer": {
"name": "hdfswriter",
"parameter": {
"defaultFS": "hdfs://namenode:9000",
"fileType": "text",
"path": "/user/data/output",
"fileName": "output_file",
"fieldDelimiter": ",",
"writeMode": "append"
}
}
}
]
}
}
```
对于更复杂的场景比如自定义编译DataX源码以适应特定需求的情形可以参考官方文档说明完成相应调整[^3]。
阅读全文
相关推荐
















