Skip to content

Commit

Permalink
Add small (4 Gb limit) clob support
Browse files Browse the repository at this point in the history
  • Loading branch information
gaellalire committed Mar 2, 2023
1 parent 7e7d1b3 commit 25fe908
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,27 @@ public final void write(ResultSet rs, Writer output) {
while (rs.next()) {
for (int i = 1; i <= columns; i++) {
row[i - 1] = rs.getObject(i);
if (row[i - 1] instanceof Clob) {
StringWriter sw = new StringWriter();
Clob clob = ((Clob) row[i - 1]);
if (clob.length() != 0) {
try {
Reader reader = clob.getCharacterStream();
try {
char[] buffer = new char[8192];
int n;
while (-1 != (n = reader.read(buffer))) {
sw.write(buffer, 0, n);
}
} finally {
reader.close();
}
} catch (Exception e) {
throw new RuntimeException("Unable to convert clob", e);
}
}
row[i - 1] = sw.toString();
}
}
if (hasWriterProcessor) {
writer.processRecord(row);
Expand Down

0 comments on commit 25fe908

Please sign in to comment.