Bug #111832 datetime columns are getting returned as LocalDateTime instead of Timestamp
Submitted: 20 Jul 2023 17:43 Modified: 21 Jul 2023 5:05
Reporter: Suman Rajagopal Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:8.0.23 OS:Any
Assigned to: CPU Architecture:Any

[20 Jul 2023 17:43] Suman Rajagopal
Description:
Starting from MySQL v8.0.23, when retrieving data from JDBC result set using getObject(colIndex), datetime column values will return as LocalDateTime object instead of Timestamp object as in previous releases. It is a breaking change as the format changed and causing the parsing logic to fail at multiple places in the application. There is no work around or a way to switch to old behavior based on a flag or sql mode.

LocalDateTime format yyyy-MM-ddThh:mm:ss

Timestamp format yyyy-MM-dd hh:mm:ss  

How to repeat:
1.Create a table and have a column of type datetime
2. Read the data from this table using JDBC API and get the value using getObject(colIndex)
3. Check the type of the object returned

Suggested fix:
Introduce a flag to return datetime type columns as Timestamp instead of LocalDateTime to retain the old behavior. JDBC driver may use this flag to decide the type of object to return.
[21 Jul 2023 5:05] MySQL Verification Team
Hello Suman Rajagopal,

Thank you for the report and feedback.
IMHO this was intended change in c/J 8.0.23+, please see Dev's( Alexander) response in Bug #102302   Please see the change log - https://dev.mysql.com/doc/relnotes/connector-j/8.0/en/news-8-0-23.html

For now, marking this as a duplicate of Bug #102302.

regards,
Umesh