【发布时间】:2016-04-26 22:34:53
【问题描述】:
我创建了一个可重用的转换,其中我有一个日期/时间格式的输入端口。
现在,当我在我的 java 代码中使用这个日期/时间端口时,它给了我不兼容的 long/date 错误。
于是我把java转换的输入端口改为String,在java转换中使用了这个字符串变量。但即使是这段代码也给了我一个错误。
Severity Timestamp Node Thread Message Code Message
INFO 26-04-2016 16:55:30 node01_Gizmo READER_1_1_1 RR_4049 RR_4049 SQL Query issued to database : (Tue Apr 26 16:55:30 2016)
INFO 26-04-2016 16:55:30 node01_Gizmo READER_1_1_1 RR_4050 RR_4050 First row returned from database to reader : (Tue Apr 26 16:55:30 2016)
INFO 26-04-2016 16:55:30 node01_Gizmo READER_1_1_1 BLKR_16019 Read [10] rows, read [0] error rows for source table [CUSTOMERS] instance name [CUSTOMERS]
INFO 26-04-2016 16:55:30 node01_Gizmo READER_1_1_1 BLKR_16008 Reader run completed.
INFO 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JAVA PLUGIN_1762 [DEBUG] Unparseable using java.text.SimpleDateFormat@9586200
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JTX_1005 [ERROR] Column name [05/06/1998 00:00:00.000000] is invalid.
INFO 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JTX_1015 [DEBUG] Exception thrown from Java transformation: [Column name [05/06/1998 00:00:00.000000] is invalid.].
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JAVA PLUGIN_1762 [ERROR] Column name [05/06/1998 00:00:00.000000] is invalid.
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JAVA PLUGIN_1762 [ERROR] at com.informatica.powercenter.server.jtx.JTXPartitionDriverImplFixed.isNull(JTXPartitionDriverImplFixed.java:737)
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JAVA PLUGIN_1762 [ERROR] at com.informatica.powercenter.server.jtx.JTXPartitionDriverImplGen.execute(JTXPartitionDriverImplGen.java:223)
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 TM_6085 A fatal error occurred at transformation [DateFormat], and the session is terminating.
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 TM_6085 A fatal error occurred at transformation [SQ_CUSTOMERS], and the session is terminating.
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 TM_6085 A fatal error occurred at transformation [SQ_CUSTOMERS], and the session is terminating.
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 TM_6085 A fatal error occurred at transformation [SQ_CUSTOMERS], and the session is terminating.
DEBUG 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 DBG_21511 TE: Fatal Transformation Error.
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8167 Start loading table [DateFormat] at: Tue Apr 26 16:55:30 2016
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8333 Rolling back all the targets due to fatal session error.
ERROR 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8170 Writer run terminated: Abort Session request received from the DTM
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8168 End loading table [DateFormat] at: Tue Apr 26 16:55:30 2016
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8035 Load complete time: Tue Apr 26 16:55:30 2016
LOAD SUMMARY
============
WRT_8036 Target: DateFormat (Instance Name: [DateFormat1])
WRT_8044 No data loaded for this target
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8043 *****END LOAD SESSION*****
Day 是 String 类型的输出端口。下面是java转换中用到的代码:
SimpleDateFormat formatter;
formatter = new SimpleDateFormat("dd-MM-yyyy");
Date my_date = null;
try{
my_date = formatter.parse(Inp_Date);
}
catch(Exception e) {
System.out.println("Unparseable using " + formatter);
}
formatter = new SimpleDateFormat("d");
Day=formatter.format(my_date);
请告诉我如何在 java 转换中使用日期/时间变量。
问候, 敏捷。
【问题讨论】:
标签: java etl informatica-powercenter