Search
Calendar
July 2025
S M T W T F S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031  
Archives

PostHeaderIcon Operand type clash: java.util.Date is incompatible with DATETIME

Case

With Mule ESB, I try to integrate an object of type java.util.Date into a column of type datetime in a Sybase DB table.
I get the following error:

 java.sql.SQLException: Operand type clash: java.util.Date is incompatible with DATETIME

Explanation – Fix

The stacktrace is explicit: java.util.Dates are not compatible with Sybase datetime, as Java’s Strings are not compatible with Sybase numeric(10, 3) for instance.
To fix the issue, you have to cast your java.util.Date as java.sql.Date or java.sql.Timestamp. The cast is very easy to perform:

private static java.sql.Timestamp javaDate2SqlTimestamp(java.util.Date javaDate){
final java.sql.Timestamp answer = new java.sql.Timestamp(javaDate.getTime());
return answer;
}

The method is quite similar for java.sql.Dates cast.

Leave a Reply