Skip to content

Commit

Permalink
Merge pull request #3429 from yidasanqian/master
Browse files Browse the repository at this point in the history
Improve getObject support, fixed #3302,#3340,#3393
  • Loading branch information
wenshao authored Sep 15, 2019
2 parents 3af2fe2 + 4486ef9 commit 73e968f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 12 additions & 3 deletions src/main/java/com/alibaba/druid/pool/DruidPooledResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Statement;
Expand Down Expand Up @@ -1763,11 +1762,21 @@ public void updateNClob(String columnLabel, Reader reader) throws SQLException {
}
}

@Override
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
return rs.getObject(columnIndex, type);
try {
return rs.getObject(columnIndex, type);
} catch (Throwable t) {
throw checkException(t);
}
}

@Override
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
return rs.getObject(columnLabel, type);
try {
return rs.getObject(columnLabel, type);
} catch (Throwable t) {
throw checkException(t);
}
}
}
14 changes: 10 additions & 4 deletions src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Statement;
Expand Down Expand Up @@ -1548,15 +1547,20 @@ public boolean wasNull() throws SQLException {
return result;
}

@Override
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
FilterChainImpl chain = createChain();
Object value = chain.resultSet_getObject(this, columnIndex, type);
T value = chain.resultSet_getObject(this, columnIndex, type);
recycleFilterChain(chain);
return (T) value;
return value;
}

@Override
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
throw new SQLFeatureNotSupportedException();
FilterChainImpl chain = createChain();
T value = chain.resultSet_getObject(this, columnLabel, type);
recycleFilterChain(chain);
return value;
}

public int getCloseCount() {
Expand Down Expand Up @@ -1604,6 +1608,7 @@ public int getOpenReaderCount() {
}

@SuppressWarnings("unchecked")
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface == ResultSetProxy.class || iface == ResultSetProxyImpl.class) {
return (T) this;
Expand All @@ -1612,6 +1617,7 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
return super.unwrap(iface);
}

@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (iface == ResultSetProxy.class || iface == ResultSetProxyImpl.class) {
return true;
Expand Down

0 comments on commit 73e968f

Please sign in to comment.