Skip to content

Commit 2f9f4dc

Browse files
committed
Removed retrieval-possibility over pipelined function
We're always using cursor now because setFetchSize is not working when using the object-pipelined-function. Instead the internal PL/SQL fetchSize is used, which is between 50 and 100 - far from immediate as we want it. Also easier to maintain.
1 parent ee1a946 commit 2f9f4dc

File tree

3 files changed

+13
-30
lines changed

3 files changed

+13
-30
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import org.utplsql.api.reporter.Reporter;
44

55
import java.io.PrintStream;
6-
import java.sql.*;
6+
import java.sql.CallableStatement;
7+
import java.sql.Connection;
8+
import java.sql.ResultSet;
9+
import java.sql.SQLException;
710
import java.util.ArrayList;
811
import java.util.List;
912
import java.util.function.Consumer;
@@ -62,8 +65,6 @@ public void printAvailable(Connection conn, List<PrintStream> printStreams) thro
6265
});
6366
}
6467

65-
protected abstract PreparedStatement getLinesStatement( Connection conn ) throws SQLException;
66-
6768
protected abstract CallableStatement getLinesCursorStatement( Connection conn ) throws SQLException;
6869

6970
/**
@@ -74,11 +75,13 @@ public void printAvailable(Connection conn, List<PrintStream> printStreams) thro
7475
*/
7576
public void fetchAvailable(Connection conn, Consumer<String> onLineFetched) throws SQLException {
7677

77-
try (PreparedStatement pstmt = getLinesStatement(conn)) {
78+
try (CallableStatement cstmt = getLinesCursorStatement(conn)) {
79+
cstmt.execute();
80+
cstmt.setFetchSize(1);
7881

79-
try (ResultSet resultSet = pstmt.executeQuery() ) {
82+
try ( ResultSet resultSet = (ResultSet) cstmt.getObject(1)) {
8083
while (resultSet.next())
81-
onLineFetched.accept(resultSet.getString(1));
84+
onLineFetched.accept(resultSet.getString("text"));
8285
}
8386
}
8487
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import java.sql.CallableStatement;
77
import java.sql.Connection;
8-
import java.sql.PreparedStatement;
98
import java.sql.SQLException;
109

1110
/** Compatibility Output-Buffer for 3.0.0 - 3.0.4
@@ -18,13 +17,6 @@ class CompatibilityOutputBufferPre310 extends AbstractOutputBuffer {
1817
super(reporter);
1918
}
2019

21-
@Override
22-
protected PreparedStatement getLinesStatement(Connection conn) throws SQLException {
23-
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM table(ut_output_buffer.get_lines(?))");
24-
pstmt.setString(1, getReporter().getId());
25-
return pstmt;
26-
}
27-
2820
@Override
2921
protected CallableStatement getLinesCursorStatement(Connection conn) throws SQLException {
3022
CallableStatement cstmt = conn.prepareCall("BEGIN ? := ut_output_buffer.get_lines_cursor(?); END;");

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
import oracle.jdbc.OracleCallableStatement;
44
import oracle.jdbc.OracleConnection;
5-
import oracle.jdbc.OraclePreparedStatement;
6-
import org.utplsql.api.reporter.Reporter;
75
import oracle.jdbc.OracleTypes;
6+
import org.utplsql.api.reporter.Reporter;
87

9-
import javax.xml.transform.Result;
10-
import java.io.PrintStream;
11-
import java.sql.*;
12-
import java.util.ArrayList;
13-
import java.util.List;
14-
import java.util.function.Consumer;
8+
import java.sql.CallableStatement;
9+
import java.sql.Connection;
10+
import java.sql.SQLException;
1511

1612
/**
1713
* Fetches the lines produced by a reporter.
@@ -29,14 +25,6 @@ class DefaultOutputBuffer extends AbstractOutputBuffer {
2925
super(reporter);
3026
}
3127

32-
@Override
33-
protected PreparedStatement getLinesStatement(Connection conn) throws SQLException {
34-
OracleConnection oraConn = conn.unwrap(OracleConnection.class);
35-
OraclePreparedStatement pstmt = (OraclePreparedStatement)oraConn.prepareStatement("select * from table(?.get_lines())");
36-
pstmt.setORAData(1, getReporter());
37-
return pstmt;
38-
}
39-
4028
@Override
4129
protected CallableStatement getLinesCursorStatement(Connection conn) throws SQLException {
4230
OracleConnection oraConn = conn.unwrap(OracleConnection.class);

0 commit comments

Comments
 (0)