Skip to content

Commit

Permalink
Defensively uses JDBC 3.0 getParameterType call for Oracle driver com…
Browse files Browse the repository at this point in the history
…patibility

Issue: SPR-10385
  • Loading branch information
jhoeller committed Mar 19, 2013
1 parent ff6d7a8 commit 6b4c29c
Showing 1 changed file with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.sql.Blob;
import java.sql.Clob;
import java.sql.DatabaseMetaData;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
Expand Down Expand Up @@ -229,18 +228,13 @@ private static void setNull(PreparedStatement ps, int paramIndex, int sqlType, S
boolean useSetObject = false;
sqlType = Types.NULL;
try {
ParameterMetaData pmd = null;
sqlType = ps.getParameterMetaData().getParameterType(paramIndex);
}
catch (Throwable ex) {
logger.debug("JDBC 3.0 getParameterType call not supported", ex);
// JDBC driver not compliant with JDBC 3.0
// -> proceed with database-specific checks
try {
pmd = ps.getParameterMetaData();
}
catch (Throwable ex) {
// JDBC driver not compliant with JDBC 3.0
// -> proceed with database-specific checks
}
if (pmd != null) {
sqlType = pmd.getParameterType(paramIndex);
}
else {
DatabaseMetaData dbmd = ps.getConnection().getMetaData();
String databaseProductName = dbmd.getDatabaseProductName();
String jdbcDriverName = dbmd.getDriverName();
Expand All @@ -255,9 +249,9 @@ else if (databaseProductName.startsWith("DB2") ||
sqlType = Types.VARCHAR;
}
}
}
catch (Throwable ex) {
logger.debug("Could not check database or driver name", ex);
catch (Throwable ex2) {
logger.debug("Could not check database or driver name", ex2);
}
}
if (useSetObject) {
ps.setObject(paramIndex, null);
Expand Down

0 comments on commit 6b4c29c

Please sign in to comment.