-
Notifications
You must be signed in to change notification settings - Fork 38.5k
JdbcTemplate should support JDBC 4.1 getObject(columnIndex, type) [SPR-11600] #16223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Juergen Hoeller commented That JdbcUtils code doesn't take JDK 7's JDBC 4.1 into account yet, which is where getObject(columnIndex, type) showed up for the first time. We'll make sure to revise that code properly, using the new getObject variant when working with a JDBC 4.1+ driver (which unfortunately isn't trivial since common drivers are known to incompletely support the latest JDBC editions). Juergen |
Juergen Hoeller commented JdbcUtils uses JDBC 4.1 getObject(int, Class) for unknown ResultSet value types on JDK 7+ now, just falling back to a regular getObject(int) call as a last resort. I've also applied a general JDBC 3.0+ baseline upgrade, removing defensive measures such as catch blocks with pre-JDBC 3.0 assumptions. Juergen |
Philippe Marschall commented Thank you |
Pavel Alexeev commented Does it already supported? In
According to source: https://github.com/spring-projects/spring-framework/blob/master/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java#L358 it known how to handle |
Philippe Marschall commented Yes it does, but your driver might not (yet). For Postgres you need version 9.4.1208 or later. You may have to set |
Pavel Alexeev commented Sure I use 9.4.1209 JDBC 42. According to http://static.javadoc.io/org.springframework/spring-jdbc/3.2.12.RELEASE/org/springframework/jdbc/core/StatementCreatorUtils.html#IGNORE_GETPARAMETERTYPE_PROPERTY_NAME it is not case. Exception happened on setValue. |
Uh oh!
There was an error while loading. Please reload this page.
Philippe Marschall opened SPR-11600 and commented
JDBC 4.2 defines the following type mappings
with can be used through
ResultSet#getObject(int, Class)
,ResultSet#getObject(String, Class)
,PreparedStatement#setObject(int, Object)
So I would expect the following to work
but it doesn't, it fails with:
Instead I have to do
The issue seems to be that
JdbcUtils.getResultSetValue(ResultSet, int, Class<?>)
callsJdbcUtils.getResultSetValue(ResultSet, int)
without the required type. I don't know if this an oversight or intentional.Affects: 4.0.2
Issue Links:
Referenced from: commits 3fef358, 3767938, c9432ce
The text was updated successfully, but these errors were encountered: