Springboot 2.2.4.RELEASE Springframework: 5.2.3.RELEASE PostgresJDBC: 42.2.11

This is causing the issue jc.setDate((OffsetDateTime)resultSet.getObject("pstime"));

However push work fine as below ps.setObject(3, OffsetDateTime.now());

Error Log:

java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.time.OffsetDateTime
    at com.accrualify.main.RouteConfiguration.lambda$null$0(RouteConfiguration.java:63) ~[classes/:?]
    at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:94) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:61) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:440) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:376) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:452) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:462) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at com.accrualify.main.RouteConfiguration.lambda$configure$4(RouteConfiguration.java:58) ~[classes/:?]

Comment From: wilkinsona

Thanks for the report but it's not clear why you believe this is a problem caused by Spring Boot. The ResultSet and the implementation of getObject(String) are provided by Postgres's JDBC driver. You also haven't given it any information about the type that you would like to be returned. Postgres' documentation recommends calling getObject(String, Class) to get the desired type back. In your case that would be the following:

jc.setDate(resultSet.getObject("pstime", OffsetDateTime.class));

If you believe there's a bug in Spring Boot that is causing the problem, please explain why and provide a small sample that reproduces the problem. We can then re-open this issue and take another look.

If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.