Generalized workaround for JDBC 4.1 getObject(index, requiredType) failures on MySQL and Derby

Issue: SPR-12174
Issue: SPR-12157
master
Juergen Hoeller 10 years ago
parent 1e7bfd91a7
commit 8922da3af6
  1. 11
      spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java

@ -25,7 +25,6 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
import java.sql.SQLDataException;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLFeatureNotSupportedException;
import java.sql.Statement; import java.sql.Statement;
@ -197,14 +196,14 @@ public abstract class JdbcUtils {
try { try {
return rs.getObject(index, requiredType); return rs.getObject(index, requiredType);
} }
catch (SQLDataException ex) { catch (AbstractMethodError err) {
logger.debug("JDBC driver has limited support for JDBC 4.1 'getObject(int, Class)' method", ex); logger.debug("JDBC driver does not implement JDBC 4.1 'getObject(int, Class)' method", err);
} }
catch (SQLFeatureNotSupportedException ex) { catch (SQLFeatureNotSupportedException ex) {
logger.debug("JDBC driver does not support JDBC 4.1 'getObject(int, Class)' method", ex); logger.debug("JDBC driver does not support JDBC 4.1 'getObject(int, Class)' method", ex);
} }
catch (AbstractMethodError err) { catch (SQLException ex) {
logger.debug("JDBC driver does not implement JDBC 4.1 'getObject(int, Class)' method", err); logger.debug("JDBC driver has limited support for JDBC 4.1 'getObject(int, Class)' method", ex);
} }
} }
// Fall back to getObject without type specification... // Fall back to getObject without type specification...
@ -219,7 +218,7 @@ public abstract class JdbcUtils {
* Retrieve a JDBC column value from a ResultSet, using the most appropriate * Retrieve a JDBC column value from a ResultSet, using the most appropriate
* value type. The returned value should be a detached value object, not having * value type. The returned value should be a detached value object, not having
* any ties to the active ResultSet: in particular, it should not be a Blob or * any ties to the active ResultSet: in particular, it should not be a Blob or
* Clob object but rather a byte array respectively String representation. * Clob object but rather a byte array or String representation, respectively.
* <p>Uses the {@code getObject(index)} method, but includes additional "hacks" * <p>Uses the {@code getObject(index)} method, but includes additional "hacks"
* to get around Oracle 10g returning a non-standard object for its TIMESTAMP * to get around Oracle 10g returning a non-standard object for its TIMESTAMP
* datatype and a {@code java.sql.Date} for DATE columns leaving out the * datatype and a {@code java.sql.Date} for DATE columns leaving out the

Loading…
Cancel
Save