# HG changeset patch # User Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> # Date 1702471797 -3600 # Node ID 17b8a0a84e62653017e9c929ae0608ae81242b10 # Parent 1344603ee8af20126ed0243df1e9fb15c5ae3596 Call reader.read multiple times if necessary diff --git a/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java b/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java --- a/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java +++ b/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java @@ -944,7 +944,13 @@ public class MonetPreparedStatement // simply serialise the Reader data into a large buffer final CharBuffer buf = CharBuffer.allocate((int)length); // have to down cast try { - reader.read(buf); + long foo = 0; + while (foo < length) { + int n = reader.read(buf); + if (n < 0) + throw new SQLException("Stream ended unexpectedly at position " + foo + " out of " + length); + foo += n; + } // We have to rewind the buffer, because otherwise toString() returns "". buf.rewind(); setString(parameterIndex, buf.toString());