proximityFlying
proximityFlying

Reputation: 183

Invalid Property on Class Timestamp

I receive an id and a timestamp from a query, and when I try to output the timestamp I receive an invalid property error. I am using ojdbc7.jar, Dataweave 2.0, and Mule 4.

Using a Transform Message I can output payload.ID[0] without issue. I tried coercing the timestamp to DateTime and formatting it as a String but it still fails.

Below works

%dw 2.0
output application/json
---
payload.ID[0]

Below gives error "Invalid property name: shareBytes on class oracle.sql.TIMESTAMP. Validate that the correct setters is presen, while writing Json at payload.CREATED_DATE.shareBytes." evaluating expression: "%dw 2.0."

%dw 2.0
output application/json
---
payload.CREATED_DATE[0]

Below gives error "Cannot coerce Object { class: oracle.sql.TIMESTAMP } (org.mule.weave.v2.module.pojo.reader.JavaBeanObjectValue@6f5eee28) to String"

%dw 2.0
output application/json
---
payload.CREATED_DATE as String {format: "dd-MMM-yy h:mm:s"}

I expected the second or third example to return the timestamp.

Upvotes: 0

Views: 3147

Answers (1)

Rafael Oltra
Rafael Oltra

Reputation: 1239

You can pass the following System (JVM) property: oracle.jdbc.J2EE13Compliant=true (as -Doracle.jdbc.J2EE13Compliant=true) to force the Oracle Driver to return java.sql.Timestamp instead of oracle.sql.Timestamp - that will allow you to coerce the java.sql.Timestamp in Dataweave

for more info on the Oracle Driver setting see https://docs.oracle.com/cd/B28359_01/java.111/b31224/datacc.htm

Upvotes: 4

Related Questions