Skip to content

Commit 6806f2b

Browse files
committed
Make fetchSize changable for outputBuffer
1 parent 8b3d668 commit 6806f2b

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
abstract class AbstractOutputBuffer implements OutputBuffer {
2121

2222
private Reporter reporter;
23+
private int fetchSize = 100;
2324

2425
/**
2526
* Creates a new DefaultOutputBuffer.
@@ -40,6 +41,11 @@ public Reporter getReporter() {
4041
return reporter;
4142
}
4243

44+
@Override
45+
public void setFetchSize(int fetchSize) {
46+
this.fetchSize = fetchSize;
47+
}
48+
4349
/**
4450
* Print the lines as soon as they are produced and write to a PrintStream.
4551
* @param conn DB connection
@@ -77,7 +83,7 @@ public void fetchAvailable(Connection conn, Consumer<String> onLineFetched) thro
7783

7884
try (CallableStatement cstmt = getLinesCursorStatement(conn)) {
7985
cstmt.execute();
80-
cstmt.setFetchSize(1);
86+
cstmt.setFetchSize(fetchSize);
8187

8288
try ( ResultSet resultSet = (ResultSet) cstmt.getObject(1)) {
8389
while (resultSet.next())
@@ -97,6 +103,7 @@ public List<String> fetchAll(Connection conn) throws SQLException {
97103
try (CallableStatement cstmt = getLinesCursorStatement(conn)) {
98104

99105
cstmt.execute();
106+
cstmt.setFetchSize(fetchSize);
100107

101108
try ( ResultSet resultSet = (ResultSet) cstmt.getObject(1)) {
102109

src/main/java/org/utplsql/api/outputBuffer/NonOutputBuffer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public Reporter getReporter() {
2626
return reporter;
2727
}
2828

29+
@Override
30+
public void setFetchSize(int fetchSize) {
31+
32+
}
33+
2934
@Override
3035
public void printAvailable(Connection conn, PrintStream ps) throws SQLException {
3136
List<PrintStream> printStreams = new ArrayList<>(1);

src/main/java/org/utplsql/api/outputBuffer/OutputBuffer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ public interface OutputBuffer {
1212

1313
Reporter getReporter();
1414

15+
/** Override the fetchSize of the OutputBuffer
16+
*
17+
* @param fetchSize the ResultSet fetch-size.
18+
*/
19+
void setFetchSize( int fetchSize );
20+
1521
/**
1622
* Print the lines as soon as they are produced and write to a PrintStream.
1723
* @param conn DB connection

src/test/java/org/utplsql/api/OutputBufferIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void printAvailableLines() throws SQLException {
5959
printStreams.add(System.out);
6060
printStreams.add(new PrintStream(fileOutStream));
6161

62+
reporter.getOutputBuffer().setFetchSize(1);
6263
reporter.getOutputBuffer().printAvailable(newConnection(), printStreams);
6364

6465
return Boolean.TRUE;

0 commit comments

Comments
 (0)