[jOOQ/jOOQ#10692] Some JDBC drivers (e.g. Informix) do not implement Wrapper::isWrapperFor

This commit is contained in:
Lukas Eder 2020-10-06 13:12:15 +02:00
parent e3a1693f4d
commit 8a4d46deb3
2 changed files with 14 additions and 1 deletions

View File

@ -95,6 +95,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Wrapper;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
@ -138,6 +139,7 @@ import org.jooq.conf.ExecuteWithoutWhere;
import org.jooq.conf.RenderNameCase;
import org.jooq.conf.SettingsTools;
import org.jooq.exception.DataAccessException;
import org.jooq.impl.DefaultUnwrapperProvider.DefaultUnwrapper;
import org.jooq.impl.Tools.BooleanDataKey;
import org.jooq.impl.Tools.DataKey;
import org.jooq.tools.JooqLogger;
@ -1160,7 +1162,7 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractRowCountQuery
* {@link BatchedPreparedStatement}, is executed immediately, not batched.
*/
private final PreparedStatement executeImmediate(PreparedStatement s) throws SQLException {
if (s.isWrapperFor(BatchedPreparedStatement.class))
if (DefaultUnwrapper.isWrapperFor(s, BatchedPreparedStatement.class))
s.unwrap(BatchedPreparedStatement.class).setExecuteImmediate(true);
return s;

View File

@ -67,6 +67,17 @@ final class DefaultUnwrapperProvider implements UnwrapperProvider {
*/
private static int maxUnwrappedStatements = 256;
static final boolean isWrapperFor(Wrapper w, Class<?> iface) {
// [#10692] Some JDBC drivers do not implement this method
try {
return w.isWrapperFor(iface);
}
catch (SQLException ignore) {
return false;
}
}
@Override
public <T> T unwrap(Wrapper wrapper, Class<T> iface) {
if (wrapper instanceof Connection)