Mercurial > hg > monetdb-java
changeset 815:17b8a0a84e62
Call reader.read multiple times if necessary
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Wed, 13 Dec 2023 13:49:57 +0100 (16 months ago) |
parents | 1344603ee8af |
children | 9188263368cc |
files | src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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());