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

Skip to content

Commit 571d95c

Browse files
author
Jacek Gębal
committed
Fixing issue with Reporter data fetching with JDBC 23 driver.
1 parent 04e3124 commit 571d95c

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void fetchAvailable(Connection conn, Consumer<String> onLineFetched) thro
9292
cstmt.execute();
9393
cstmt.setFetchSize(fetchSize);
9494

95-
try (ResultSet resultSet = (ResultSet) cstmt.getObject(1)) {
95+
try (ResultSet resultSet = (ResultSet) cstmt.getObject("lines_cursor")) {
9696
while (resultSet.next()) {
9797
onLineFetched.accept(resultSet.getString("text"));
9898
}
@@ -114,7 +114,7 @@ public List<String> fetchAll(Connection conn) throws SQLException {
114114
cstmt.execute();
115115
cstmt.setFetchSize(fetchSize);
116116

117-
try (ResultSet resultSet = (ResultSet) cstmt.getObject(1)) {
117+
try (ResultSet resultSet = (ResultSet) cstmt.getObject("lines_cursor")) {
118118

119119
List<String> outputLines = new ArrayList<>();
120120
while (resultSet.next()) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class CompatibilityOutputBufferPre310 extends AbstractOutputBuffer {
2020

2121
@Override
2222
protected CallableStatement getLinesCursorStatement(Connection conn) throws SQLException {
23-
CallableStatement cstmt = conn.prepareCall("BEGIN ? := ut_output_buffer.get_lines_cursor(?); END;");
24-
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
25-
cstmt.setString(2, getReporter().getId());
23+
CallableStatement cstmt = conn.prepareCall("begin :lines_cursor := ut_output_buffer.get_lines_cursor(:reporter_id); end;");
24+
cstmt.registerOutParameter("lines_cursor", OracleTypes.CURSOR);
25+
cstmt.setString("reporter_id", getReporter().getId());
2626
return cstmt;
2727
}
2828
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ class DefaultOutputBuffer extends AbstractOutputBuffer {
2828
@Override
2929
protected CallableStatement getLinesCursorStatement(Connection conn) throws SQLException {
3030
Reporter reporter = getReporter();
31-
String plsql = "DECLARE" +
32-
" l_rep " + reporter.getTypeName() + " := " + reporter.getTypeName() +"(); " +
33-
"BEGIN" +
34-
" l_rep.set_reporter_id(:1); " +
35-
" :2 := l_rep.get_lines_cursor(); " +
36-
"END;";
31+
String plsql = "declare" +
32+
" l_rep " + reporter.getTypeName() + " := " + reporter.getTypeName() + "(); " +
33+
"begin" +
34+
" l_rep.set_reporter_id(:reporter_id); " +
35+
" :lines_cursor := l_rep.get_lines_cursor(); " +
36+
"end;";
3737
OracleCallableStatement cstmt = (OracleCallableStatement) conn.prepareCall(plsql);
38-
cstmt.setString(1, reporter.getId());
39-
cstmt.registerOutParameter(2, OracleTypes.CURSOR);
38+
cstmt.setString("reporter_id", reporter.getId());
39+
cstmt.registerOutParameter("lines_cursor", OracleTypes.CURSOR);
4040
return cstmt;
4141
}
4242
}

0 commit comments

Comments
 (0)