{"record":{"id":"a0a456effc859e1e","repo":"apache/shardingsphere","slug":"0-a0a456","errorCode":"0","errorMessage":"Unknown exception.","messagePattern":"Unknown exception\\.","errorType":"exception","errorClass":"UnknownSQLException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractPreparedStatementAdapter.java","lineNumber":216,"sourceCode":"        setParameter(parameterIndex, x);\n    }\n    \n    @Override\n    public final void setBinaryStream(final int parameterIndex, final InputStream x, final int length) {\n        setParameter(parameterIndex, x);\n    }\n    \n    @Override\n    public final void setBinaryStream(final int parameterIndex, final InputStream x, final long length) {\n        setParameter(parameterIndex, x);\n    }\n    \n    @Override\n    public final void setCharacterStream(final int parameterIndex, final Reader x) {\n        try {\n            setParameter(parameterIndex, CharStreams.toString(x));\n        } catch (final IOException ex) {\n            throw new UnknownSQLException(ex);\n        }\n    }\n    \n    @Override\n    public final void setCharacterStream(final int parameterIndex, final Reader x, final int length) {\n        try {\n            setParameter(parameterIndex, CharStreams.toString(x));\n        } catch (final IOException ex) {\n            throw new UnknownSQLException(ex);\n        }\n    }\n    \n    @Override\n    public final void setCharacterStream(final int parameterIndex, final Reader x, final long length) {\n        try {\n            setParameter(parameterIndex, CharStreams.toString(x));\n        } catch (final IOException ex) {\n            throw new UnknownSQLException(ex);","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractPreparedStatementAdapter.java#L198-L234","documentation":"UnknownSQLException (a runtime wrapper) thrown by AbstractPreparedStatementAdapter.setCharacterStream(Reader) when Guava's CharStreams.toString(x) fails with IOException while draining the Reader into a String parameter. The JDBC API declares no checked IOException, so the I/O failure is converted to this 'Unknown exception.' runtime type.","triggerScenarios":"Calling setCharacterStream(int, Reader) (single-arg variant) on a ShardingSphere PreparedStatement when the supplied Reader throws while being read — closed Reader, broken pipe on a stream-backed Reader, or interrupted I/O.","commonSituations":"Passing a Reader over a closed or already-consumed stream (e.g. reading request bodies or files twice); FileReader on a file deleted mid-read; NIO_CharStream decode errors; wrapping stream resources closed by try-with-resources before execute.","solutions":["Check the Reader is open and at the expected position before binding it; do not reuse an already-consumed Reader.","Read the character data into a String yourself (with explicit error handling) and use setString instead, so the IOException is handled at your call site.","Ensure the underlying stream/file remains open until execute completes, not just until setCharacterStream returns."],"exampleFix":"// before\nstmt.setCharacterStream(1, reader);\n// after\nString text;\ntry {\n    text = CharStreams.toString(reader);\n} catch (IOException ex) {\n    throw new IllegalArgumentException(\"bad stream param\", ex);\n}\nstmt.setString(1, text);","handlingStrategy":"validation","validationCode":"if (reader == null) throw new IllegalArgumentException(); // and confirm source stream is open","typeGuard":null,"tryCatchPattern":"catch (UnknownSQLException ex) { unwrap IOException cause; report which parameter Reader failed; }","preventionTips":["Pre-read Reader into String with explicit IOException handling and use setString","Never pass an already-consumed or closed Reader","Keep the backing stream alive until execute"],"tags":["jdbc","prepared-statement","io","runtime-wrapper"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}