将负整数转换为字符串 Talend open studio

发布于 2025-01-20 20:44:00 字数 619 浏览 5 评论 0原文

我此 Talend 作业的目标是将 excel 中的数据插入 mysql 数据库。当我输入Excel文件时,Active Case的列是字符串,它包含一些负整数。

但是,我想稍后将其以整数形式存储在 mysql 数据库中。以下是Tmap中的代码。我想将所有负整数存储在数据库以及整数字段中。即使我解析为 int,这里的问题是什么。

`Var.var9==null||Var.var9==""?0:Integer.parseInt(Var.var9)`

原始数据 Excel 文件

Talend 作业

Tmap

错误消息

My objective for this Talend Job is to insert the the data from excel into the mysql db. When i input the excel file, the column of Active Case is string which it contains some negative integer.

However, i want to store this as in integer later in the mysql db. The following is the code in Tmap. My want to store all the negative integers in db as well as integer field. What is the issue here even though i parse as int.

`Var.var9==null||Var.var9==""?0:Integer.parseInt(Var.var9)`

Raw Data Excel File

Talend Job

Tmap

Error Message

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尸血腥色 2025-01-27 20:44:00

如果您的读取输入为null或否(“”),则插入0。其他任何内容都用作数字。错误消息表明您的Excel中只有一行,其中仅包含“ - ”。您可以通过这样的尝试来轻松地复制此问题:

Integer i = Integer.parseInt("-");

您将获得相同的错误消息

Caused by: java.lang.NumberFormatException: For input string: "-"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:572)
at java.lang.Integer.parseInt(Integer.java:615)

如果您的Excel确实不仅包含“ - ”您的分析数据中的“ - ”,那么 ,那么您应该提供更多的代码。错误可能在您的解析过程中。

If your read Input is null or nothing ("") you insert 0. Anything else is used as a number. The error message indicates that there is a row in your excel which only contains "-". You can easily reproduce this by trying it out like this:

Integer i = Integer.parseInt("-");

You the get the same error message

Caused by: java.lang.NumberFormatException: For input string: "-"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:572)
at java.lang.Integer.parseInt(Integer.java:615)

If your excel really does not contain just a "-" in your parsed data, then you should provide more of your code. The error may be in your parsing process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文