Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e677de7

Browse files
configure default fetch size of 100 (except for consumeReport)
1 parent 22610ee commit e677de7

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

sqldev/src/main/java/org/utplsql/sqldev/dal/RealtimeReporterDao.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class RealtimeReporterDao {
6464
public RealtimeReporterDao(final Connection conn) {
6565
this.conn = conn;
6666
jdbcTemplate = new JdbcTemplate(new SingleConnectionDataSource(conn, true));
67-
jdbcTemplate.setFetchSize(1);
67+
jdbcTemplate.setFetchSize(UtplsqlDao.FETCH_ROWS);
6868
}
6969

7070
public boolean isSupported() {
@@ -143,26 +143,31 @@ public void consumeReport(final String reporterId, final RealtimeReporterEventCo
143143
sb.append(" ? := l_reporter.get_lines_cursor();\n");
144144
sb.append("END;");
145145
final String plsql = sb.toString();
146-
jdbcTemplate.execute(plsql, new CallableStatementCallback<Void>() {
147-
@Override
148-
public Void doInCallableStatement(final CallableStatement cs) throws SQLException {
149-
cs.setString(1, reporterId);
150-
cs.registerOutParameter(2, OracleTypes.CURSOR);
151-
cs.execute();
152-
final ResultSet rs = (ResultSet) cs.getObject(2);
153-
while (rs.next()) {
154-
final String itemType = rs.getString("item_type");
155-
final Clob textClob = rs.getClob("text");
156-
final String textString = textClob.getSubString(1, ((int) textClob.length()));
157-
final RealtimeReporterEvent event = convert(itemType, textString);
158-
if (event != null) {
159-
consumer.process(event);
146+
jdbcTemplate.setFetchSize(1);
147+
try {
148+
jdbcTemplate.execute(plsql, new CallableStatementCallback<Void>() {
149+
@Override
150+
public Void doInCallableStatement(final CallableStatement cs) throws SQLException {
151+
cs.setString(1, reporterId);
152+
cs.registerOutParameter(2, OracleTypes.CURSOR);
153+
cs.execute();
154+
final ResultSet rs = (ResultSet) cs.getObject(2);
155+
while (rs.next()) {
156+
final String itemType = rs.getString("item_type");
157+
final Clob textClob = rs.getClob("text");
158+
final String textString = textClob.getSubString(1, ((int) textClob.length()));
159+
final RealtimeReporterEvent event = convert(itemType, textString);
160+
if (event != null) {
161+
consumer.process(event);
162+
}
160163
}
164+
rs.close();
165+
return null;
161166
}
162-
rs.close();
163-
return null;
164-
}
165-
});
167+
});
168+
} finally {
169+
jdbcTemplate.setFetchSize(UtplsqlDao.FETCH_ROWS);
170+
}
166171
}
167172

168173
public String getHtmlCoverage(final String reporterId) {

sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class UtplsqlDao {
4242
public static final int FIRST_VERSION_WITH_ANNOTATION_API = 3001003;
4343
public static final int FIRST_VERSION_WITHOUT_INTERNAL_API = 3001008;
4444
public static final int FIRST_VERSION_WITH_HAS_SUITES_API = 3001008;
45+
public static final int FETCH_ROWS = 100;
4546
private JdbcTemplate jdbcTemplate;
4647
// cache fields
4748
private Boolean cachedDbaViewAccessible;
@@ -50,6 +51,7 @@ public class UtplsqlDao {
5051

5152
public UtplsqlDao(final Connection conn) {
5253
jdbcTemplate = new JdbcTemplate(new SingleConnectionDataSource(conn, true));
54+
jdbcTemplate.setFetchSize(FETCH_ROWS);
5355
}
5456

5557
/**

0 commit comments

Comments
 (0)