Mulesoft - 未能在数据库中侦听(MySQL 连接)

Mulesoft - Failure to listen in database (MySQL Connection)

我已经创建了一个数据库连接器 (MySQL)。使用“在 Table 行”并执行项目时,出现此错误:

ERROR 2021-06-10 12:46:59,830 [_pollingSource_LocalBD_FlowTest/executor.01] [event: ] org.mule.extension.db.internal.source.RowListener: Failed to query table 'myTable' for new rows. Value '0000-00-00' can not be represented as java.sql.Date
java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
In data base there is a column "Date" with value 0000-00-00

我安装了其他驱动(先是推荐的(5.1.48),现在是最后一个版本(8.0.25)),出现其他错误:

ERROR 2021-06-10 12:52:33,153 [_pollingSource_LocalBD_FlowTest/executor.01] [event: ] org.mule.extension.db.internal.source.RowListener: Failed to query table 'myTable' for new rows. Zero date value prohibited
java.sql.SQLException: Zero date value prohibited

如何解决无需修改数据库

谢谢

这是 MySQL 处理日期的问题。出于某种原因,它允许使用 zero month which is not valid:

创建日期字段

MySQL permits you to store a “zero” value of '0000-00-00' as a “dummy date.” In some cases, this is more convenient than using NULL values, and uses less data and index space. To disallow '0000-00-00', enable the NO_ZERO_DATE mode.

MYSQL JDBC driver 对此的抱怨是正确的,因为它不是有效日期。月份不能为零。

显然有一个解决方法,向 JDBC URL 添加一个参数,以便 driver 将任何 'zero dates' 转换为 NULL:?zeroDateTimeBehavior=convertToNull .这个previous answer.

里面提到了

我建议完全避免在数据库中使用这种零日期,但如果您无法避免,该参数应该可以解决它。