prestodb/presto · error · NotImplementedException

Not implemented: PreparedStatement.setCharacterStream

Error message

Not implemented: PreparedStatement.setCharacterStream

What it means

Presto's JDBC driver does not implement setCharacterStream; the method unconditionally throws NotImplementedException. Character stream parameters are not supported by the wire protocol mapping in this driver.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java:482

                    batchUpdateCounts[i] = getUpdateCount();
                }
                catch (SQLException e) {
                    long[] updateCounts = Arrays.stream(batchUpdateCounts).mapToLong(j -> j).toArray();
                    throw new BatchUpdateException(e.getMessage(), e.getSQLState(), e.getErrorCode(), updateCounts, e.getCause());
                }
            }
            return batchUpdateCounts;
        }
        finally {
            clearBatch();
        }
    }

    @Override
    public void setCharacterStream(int parameterIndex, Reader reader, int length)
            throws SQLException
    {
        throw new NotImplementedException("PreparedStatement", "setCharacterStream");
    }

    @Override
    public void setRef(int parameterIndex, Ref x)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("setRef");
    }

    @Override
    public void setBlob(int parameterIndex, Blob x)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("setBlob");
    }

    @Override
    public void setClob(int parameterIndex, Clob x)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Read the Reader into a String and call setString instead.
  2. If the text is large, chunk it and build the value before binding.
  3. Do not attempt to pass Reader/InputStream directly to Presto JDBC.

Example fix

// before
ps.setCharacterStream(1, reader, length);
// after
String text = new BufferedReader(reader).lines().collect(Collectors.joining("\n"));
ps.setString(1, text);
Defensive patterns

Strategy: fallback

Validate before calling

if (value instanceof Reader) { /* do not call setCharacterStream on Presto; read to String */ }

Prevention

When it happens

Trigger: Calling PreparedStatement.setCharacterStream(int, Reader, int) (or its overloads) on a Presto connection.

Common situations: Porting legacy JDBC code written for MySQL/Oracle drivers that streams large text into CLOB/text columns.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/46f71a0b78caa60d. Report an issue: GitHub.