Consider the following DDL I am using to create an H2 database table in one of my JUnit test cases :
CREATE TABLE "CONFIG_INFO"
( "ID" VARCHAR2(12 BYTE),
"RUN_DATE" DATE,
);
The class that I am writing a unit test for tries to insert a record in this table. I can see that the following query is executed for inserting a record :
insert into CONFIG_INFO(ID,RUN_DATE) values (?,?)
However, the insertion fails with the following exception :
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [insert into CONFIG_INFO(ID,RUN_DATE) values (?,?)]; Cannot parse "DATE" constant "31-Jan-20";
I looked around and found that this issue usually occurs when you have a time component as part of the date; however, debugged the code and I can see that the Java code is passing "31-Jan-20" with no time stamp component as can also be seen from the error message above.
How can I resolve this error?