{"record":{"id":"73f7d0a1f4d701e4","repo":"OtterMind/Chat2DB","slug":"largecellvalue-readfailed","errorCode":"largeCellValue.readFailed","errorMessage":"largeCellValue.readFailed","messagePattern":"largeCellValue\\.readFailed","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbCellValueServiceImpl.java","lineNumber":76,"sourceCode":"                readCellValueChunkRequest == null ? null : readCellValueChunkRequest.getFormat());\n        long offset = Math.max(0L, offsetParam == null ? 0L : offsetParam);\n        int limit = normalizeLimit(limitParam, format);\n        try (PreparedStatement statement = prepareStatement(reference);\n             ResultSet resultSet = statement.executeQuery()) {\n            if (!resultSet.next()) {\n                throw new BusinessException(\"largeCellValue.rowNotFound\");\n            }\n            Object value = resultSet.getObject(1);\n            int sqlType = reference.getSqlType() == null ? resultSet.getMetaData().getColumnType(1) : reference.getSqlType();\n            String columnType = StringUtils.defaultIfBlank(reference.getColumnType(),\n                    resultSet.getMetaData().getColumnTypeName(1));\n            LargeValueTypeEnum valueType = LargeValueTypeEnum.resolveForRead(value, columnType, sqlType,\n                    reference.getValueType());\n            return valueType.isBinaryLike()\n                    ? readBinaryChunk(resultSet, value, offset, limit, format, reference, valueType)\n                    : readTextChunk(resultSet, value, offset, limit, format, reference, valueType);\n        } catch (SQLException | IOException e) {\n            throw new BusinessException(\"largeCellValue.readFailed\", new Object[]{e.getMessage()}, e);\n        }\n    }\n\n    @Override\n    public CellValueDownload prepareDownload(LargeValueReference reference, String format) {\n        try (PreparedStatement statement = prepareStatement(reference);\n             ResultSet resultSet = statement.executeQuery()) {\n            if (!resultSet.next()) {\n                throw new BusinessException(\"largeCellValue.rowNotFound\");\n            }\n            Object value = resultSet.getObject(1);\n            int sqlType = reference.getSqlType() == null ? resultSet.getMetaData().getColumnType(1) : reference.getSqlType();\n            String columnType = StringUtils.defaultIfBlank(reference.getColumnType(),\n                    resultSet.getMetaData().getColumnTypeName(1));\n            LargeValueTypeEnum valueType = LargeValueTypeEnum.resolveForRead(value, columnType, sqlType,\n                    reference.getValueType());\n            CellValueFormatEnum outputFormat = CellValueFormatEnum.fromRequest(format).forDownload();\n            BinaryContentTypeEnum binaryContentType = valueType.isBinaryLike()","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbCellValueServiceImpl.java#L58-L94","documentation":"Wraps any SQLException or IOException raised while reading a chunked large cell value (executing the prepared statement, getObject, streaming binary/text). The original exception's message is passed as the first format arg and the throwable is chained.","triggerScenarios":"readChunk() executes the SELECT and the read path throws SQLException (connection dropped, data type conversion error, permission revoked) or IOException (stream read failure during readBinaryChunk/readTextChunk).","commonSituations":"Connection reset mid-stream on a LOB/CLOB, dialect returning an object the reader cannot coerce, blob stream closed prematurely by the driver, or transient network blips to the DB.","solutions":["Inspect the chained cause (e.getMessage() in the args and the throwable) to find the real JDBC/IO error.","For transient SQLExceptions (connection reset, timeout), retry after re-establishing the connection context.","For type-conversion errors, confirm the LargeValueReference.sqlType/columnType matches the actual column.","Reopen the cell from a refreshed result set to regenerate the reference."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    cellValueService.readChunk(request);\n} catch (BusinessException e) {\n    if (\"largeCellValue.readFailed\".equals(e.getCode()) && e.getCause() != null) {\n        // inspect e.getCause() (SQLException/IOException) for the real reason\n        // retry once if it is a transient connection error\n    } else {\n        throw e;\n    }\n}","preventionTips":["Log the chained cause, not just the wrapped message, for diagnosis.","Reconnect before retrying readChunk when the cause is a connection drop.","Confirm reference.sqlType/columnType match the column to avoid conversion errors."],"tags":["cell-value","large-value","jdbc","io","streaming"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}