mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve java.sql.Wrapper support
This commit is contained in:
@@ -375,10 +375,10 @@ public class ConnectionProxyImpl extends WrapperProxyImpl implements ConnectionP
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (iface == Connection.class) {
|
||||
return (T) connection;
|
||||
if (iface == this.getClass() || iface == ConnectionProxy.class) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
return super.unwrap(iface);
|
||||
}
|
||||
|
||||
|
||||
@@ -473,13 +473,4 @@ public class PreparedStatementProxyImpl extends StatementProxyImpl implements Pr
|
||||
public String getLastExecuteSql() {
|
||||
return this.sql;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (iface == PreparedStatement.class) {
|
||||
return (T) statement;
|
||||
}
|
||||
|
||||
return super.unwrap(iface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,15 +1071,6 @@ public class ResultSetProxyImpl extends WrapperProxyImpl implements ResultSetPro
|
||||
throw new SQLFeatureNotSupportedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (iface == ResultSet.class) {
|
||||
return (T) resultSet;
|
||||
}
|
||||
|
||||
return super.unwrap(iface);
|
||||
}
|
||||
|
||||
public int getCloseCount() {
|
||||
return closeCount;
|
||||
}
|
||||
|
||||
@@ -393,15 +393,6 @@ public class StatementProxyImpl extends WrapperProxyImpl implements StatementPro
|
||||
throw new SQLFeatureNotSupportedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (iface == Statement.class) {
|
||||
return (T) statement;
|
||||
}
|
||||
|
||||
return super.unwrap(iface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, JdbcParameter> getParameters() {
|
||||
return Collections.emptyMap();
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class WrapperProxyImpl implements WrapperProxy {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (iface.isInstance(this)) {
|
||||
if (iface == this.getClass()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ public abstract class WrapperProxyImpl implements WrapperProxy {
|
||||
if (iface == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (iface.isInstance(this)) {
|
||||
|
||||
if (iface == this.getClass()) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user