Skip to content

Commit

Permalink
RowSetFactory is costly to build and is built very often
Browse files Browse the repository at this point in the history
  • Loading branch information
reda-alaoui committed Oct 11, 2024
1 parent 3c4b168 commit 681f0cb
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
@IgnoreJRERequirement
public class CachedRowSetResultSetProxyLogicFactory implements ResultSetProxyLogicFactory {

private final RowSetFactory rowSetFactory;

public CachedRowSetResultSetProxyLogicFactory() {
try {
this.rowSetFactory = RowSetProvider.newFactory();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

@Override
public ResultSetProxyLogic create(ResultSet resultSet, ConnectionInfo connectionInfo, ProxyConfig proxyConfig) {
ResultSet cachedRowSet = getCachedRowSet(resultSet);
Expand All @@ -40,7 +50,6 @@ protected ResultSet getCachedRowSet(ResultSet resultSet) {
try {
// CachedRowSet only works with non-null ResultSet
if (resultSet.getMetaData().getColumnCount() > 0) {
RowSetFactory rowSetFactory = RowSetProvider.newFactory();
CachedRowSet cachedRowSet = rowSetFactory.createCachedRowSet();
cachedRowSet.populate(resultSet);
return cachedRowSet;
Expand Down

0 comments on commit 681f0cb

Please sign in to comment.