0

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.

MT0
  • 143,790
  • 11
  • 59
  • 117
  • Use `LocalDateTime`. Check [this answer](https://stackoverflow.com/a/67752047/10819573) and [this answer](https://stackoverflow.com/a/67505173/10819573) to learn more. – Arvind Kumar Avinash Dec 16 '22 at 10:39

1 Answers1

0

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()
    }
}
erayerdem
  • 775
  • 6
  • 12