I'm trying to query some data from a MySQL database using the following query:
String query = "SELECT * FROM my_table WHERE Timestamp > '" + startDate + "'";
The column Timestamp is DATETIME.
The variable startDate is an object of type ZonedDateTime, obtained as follows:
Date start = ...;
ZonedDateTime startDate= ZonedDateTime.ofInstant(start.toInstant(),ZoneId.of(cachedResource.getHistorizationParameters().getTimeZone()));
This gives me the following ZonedDateTime: 2021-08-17T09:22:29+02:00[Europe/Madrid] , which is making the queries fail when I execute them:
java.sql.SQLException: Incorrect DATETIME value: '2021-08-17T09:22:29+02:00[Europe/Madrid]'
Other ZonedDateTimes have worked in the past, I don't know what is going wrong and I would really appreciate some directions on solving this problem.
Thanks!