简体   繁体   中英

Mapping Error: oracle.sql.TIMESTAMP to java.util.Date while using Apache Camel

I am using Apache Camel framework of java in which I am fetching the data from oracle db with a column of type timestamp . When I am trying to map this to variable of type java.util.Date , it is throwing the following error mentioned.

Caused by: java.lang.IllegalArgumentException:
Could not find a suitable setter for property lastupdated as there isn't a setter method with same type oracle.sql.TIMESTAMP nor type conversion possible: 
No type converter available to convert from type oracle.sql.TIMESTAMP to the required type java.util.Date with value "2022-11-16 19:04:27.067"

Can anyone help me with this?

I tried to use the following datatypes of java-

  1. java.util.Date
  2. oracle.sql.TIMESTAMP
  3. java.sql.Timestamp

But still the error is same.

create a camel convertor and add it camel context annotation can be change for spring + camel or quarkus + camel it is basic camel annotation

@Converter(generateLoader = true)
public class DateConvertor {
    @Converter
    public static java.sql.Timestamp toTimeStamp(oracle.sql.TIMESTAMP timestamp) {
        return timestamp.timestampValue()
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM