Skip to content

Commit baa4421

Browse files
committed
Merge pull request #115 from reda-alaoui
* cache-row-set-factory: Polish "RowSetFactory is costly to build and is built very often" RowSetFactory is costly to build and is built very often Closes gh-115
2 parents 3c4b168 + 838ed45 commit baa4421

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main/java/net/ttddyy/dsproxy/proxy/CachedRowSetResultSetProxyLogicFactory.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
@IgnoreJRERequirement
3131
public class CachedRowSetResultSetProxyLogicFactory implements ResultSetProxyLogicFactory {
3232

33+
private final RowSetFactory rowSetFactory;
34+
35+
public CachedRowSetResultSetProxyLogicFactory() {
36+
try {
37+
this.rowSetFactory = RowSetProvider.newFactory();
38+
} catch (SQLException ex) {
39+
throw new RuntimeException(ex);
40+
}
41+
}
42+
3343
@Override
3444
public ResultSetProxyLogic create(ResultSet resultSet, ConnectionInfo connectionInfo, ProxyConfig proxyConfig) {
3545
ResultSet cachedRowSet = getCachedRowSet(resultSet);
@@ -40,8 +50,7 @@ protected ResultSet getCachedRowSet(ResultSet resultSet) {
4050
try {
4151
// CachedRowSet only works with non-null ResultSet
4252
if (resultSet.getMetaData().getColumnCount() > 0) {
43-
RowSetFactory rowSetFactory = RowSetProvider.newFactory();
44-
CachedRowSet cachedRowSet = rowSetFactory.createCachedRowSet();
53+
CachedRowSet cachedRowSet = this.rowSetFactory.createCachedRowSet();
4554
cachedRowSet.populate(resultSet);
4655
return cachedRowSet;
4756
} else {

0 commit comments

Comments
 (0)