Skip to content

Commit 8922da3

Browse files
committed
Generalized workaround for JDBC 4.1 getObject(index, requiredType) failures on MySQL and Derby
Issue: SPR-12174 Issue: SPR-12157
1 parent 1e7bfd9 commit 8922da3

File tree

1 file changed

+5
-6
lines changed
  • spring-jdbc/src/main/java/org/springframework/jdbc/support

1 file changed

+5
-6
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.sql.DatabaseMetaData;
2626
import java.sql.ResultSet;
2727
import java.sql.ResultSetMetaData;
28-
import java.sql.SQLDataException;
2928
import java.sql.SQLException;
3029
import java.sql.SQLFeatureNotSupportedException;
3130
import java.sql.Statement;
@@ -197,14 +196,14 @@ else if (Clob.class.equals(requiredType)) {
197196
try {
198197
return rs.getObject(index, requiredType);
199198
}
200-
catch (SQLDataException ex) {
201-
logger.debug("JDBC driver has limited support for JDBC 4.1 'getObject(int, Class)' method", ex);
199+
catch (AbstractMethodError err) {
200+
logger.debug("JDBC driver does not implement JDBC 4.1 'getObject(int, Class)' method", err);
202201
}
203202
catch (SQLFeatureNotSupportedException ex) {
204203
logger.debug("JDBC driver does not support JDBC 4.1 'getObject(int, Class)' method", ex);
205204
}
206-
catch (AbstractMethodError err) {
207-
logger.debug("JDBC driver does not implement JDBC 4.1 'getObject(int, Class)' method", err);
205+
catch (SQLException ex) {
206+
logger.debug("JDBC driver has limited support for JDBC 4.1 'getObject(int, Class)' method", ex);
208207
}
209208
}
210209
// Fall back to getObject without type specification...
@@ -219,7 +218,7 @@ else if (Clob.class.equals(requiredType)) {
219218
* Retrieve a JDBC column value from a ResultSet, using the most appropriate
220219
* value type. The returned value should be a detached value object, not having
221220
* any ties to the active ResultSet: in particular, it should not be a Blob or
222-
* Clob object but rather a byte array respectively String representation.
221+
* Clob object but rather a byte array or String representation, respectively.
223222
* <p>Uses the {@code getObject(index)} method, but includes additional "hacks"
224223
* to get around Oracle 10g returning a non-standard object for its TIMESTAMP
225224
* datatype and a {@code java.sql.Date} for DATE columns leaving out the

0 commit comments

Comments
 (0)