Skip to content

Commit 8b3d668

Browse files
authored
Merge pull request #51 from utPLSQL/bugfix/immediate_feedback_output_buffer
Bugfix/immediate feedback output buffer
2 parents ee1a946 + 4c4fe12 commit 8b3d668

File tree

5 files changed

+18
-39
lines changed

5 files changed

+18
-39
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);

src/main/java/org/utplsql/api/reporter/Reporter.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import oracle.jdbc.OracleTypes;
66
import oracle.sql.Datum;
77
import oracle.sql.ORAData;
8-
import oracle.sql.STRUCT;
9-
import oracle.sql.StructDescriptor;
108
import org.utplsql.api.compatibility.CompatibilityProxy;
119
import org.utplsql.api.outputBuffer.OutputBuffer;
1210

@@ -103,9 +101,7 @@ public String getId() {
103101

104102
public Datum toDatum(Connection c) throws SQLException
105103
{
106-
StructDescriptor sd =
107-
StructDescriptor.createDescriptor(getTypeName(), c);
108-
return new STRUCT(sd, c, getAttributes());
104+
return (Datum)c.createStruct(getTypeName(), getAttributes());
109105
}
110106

111107
public OutputBuffer getOutputBuffer() {

src/main/java/org/utplsql/api/reporter/ReporterFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import oracle.sql.Datum;
44
import oracle.sql.ORAData;
55
import oracle.sql.ORADataFactory;
6-
import oracle.sql.STRUCT;
76
import org.utplsql.api.compatibility.CompatibilityProxy;
87

98
import java.sql.SQLException;
9+
import java.sql.Struct;
1010
import java.util.HashMap;
1111
import java.util.Map;
1212
import java.util.function.BiFunction;
@@ -117,9 +117,9 @@ public Map<String, String> getRegisteredReporterInfo() {
117117
@Override
118118
public ORAData create(Datum d, int sqlType) throws SQLException {
119119
if (d == null) return null;
120-
if ( d instanceof STRUCT) {
121-
String sqlName = ((STRUCT)d).getDescriptor().getName();
122-
return createReporter(sqlName, ((STRUCT)d).getAttributes());
120+
if ( d instanceof Struct) {
121+
String sqlName = ((Struct)d).getSQLTypeName();
122+
return createReporter(sqlName, ((Struct)d).getAttributes());
123123
}
124124

125125
return null;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy