mysql - Talend 无法将列解析为时间戳

标签 mysql mariadb talend

在这个问题上我需要你的帮助,

我有一个 talend 作业,它使用简单的 tmap 将数据从一个表加载到另一个表。

我称它为神秘错误,因为它只发生在特定的日期时间

java.sql.SQLException: Could not parse column as timestamp, was: "2009-06-01 00:00:00"    

包含此行的行之前的数千行不会生成错误

当我将此日期 2009-06-01 00:00:00 修改为另一个日期或只是更改日期部分或月份甚至小时时,它会没有错误。

数据源是ma​​riadb,目标是Mysql数据库

谢谢你的帮助

enter image description here enter image description here

enter image description here

这是包含生成的错误的代码部分

                    if (colQtyInRs_tMysqlInput_5 < 6) {
                        row5.created_at = null;
                    } else {

                        if (rs_tMysqlInput_5.getString(6) != null) {
                            String dateString_tMysqlInput_5 = rs_tMysqlInput_5
                                    .getString(6);
                            if (!("0000-00-00")
                                    .equals(dateString_tMysqlInput_5)
                                    && !("0000-00-00 00:00:00")
                                            .equals(dateString_tMysqlInput_5)) {
                                row5.created_at = rs_tMysqlInput_5
                                        .getTimestamp(6);
                            } else {
                                row5.created_at = (java.util.Date) year0_tMysqlInput_5
                                        .clone();
                            }
                        } else {
                            row5.created_at = null;
                        }
                    }

最佳答案

由于您在

中没有提供更多信息
  • 源数据的外观,例如源中是日期字段还是字符串字段?

  • 为什么会解析,这好像跟源数据是字符串有关

  • 解析模式的样子

我将在这里假设一些。

1st:我假设您在源代码中提供了一个字符串。由于是这种情况,您需要确保列中的日期始终采用相同的格式。此外,您需要向我们展示用于解析的时间戳格式。

2nd:您说您需要更改日期值才能正常工作。在我看来,这似乎是解析的问题,例如,您不小心切换了月份和日期字段,例如yyyy-dd-mm HH:mm:ss 或类似的东西。同样,这取决于您的解析字符串。

因为这个 I created a blog post for date handling in Talend 经常让人有点困惑您也可以引用。

关于mysql - Talend 无法将列解析为时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45792622/

相关文章:

MySQL 统计引用外键的属性

phpmyadmin : Depends: php-twig (>= 2. 9) 但要安装 2.6.2-2。什么?

mysql优化UPDATE JOIN性能指标

talend - 在 Talend 中捕获数据错误

oracle - talend - 指定 jndi 作为数据源

mysql - 如何将多个类(相同的实体但具有增强的属性)映射到同一个数据库表?

php - 使用 PHP/MYSQL 进行基于对话的消息传递?

mysql - 错误#1046 : Data too long for column but both source and destination columns are of type char(1)

hadoop - 连接 talend 和 Hadoop

sql - 为什么这个 mysql 表在日期时间字段中产生 NULL?