{"record":{"id":"4fb245d45482fa68","repo":"NationalSecurityAgency/ghidra","slug":"error-during-insertion","errorCode":null,"errorMessage":"Error during insertion","messagePattern":"Error during insertion","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/SQLStringTable.java","lineNumber":261,"sourceCode":"\t\ts.setString(1, value);\n\t\ttry (ResultSet rs = s.executeQuery()) {\n\t\t\tif (!rs.next()) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\tid = rs.getInt(1);\n\t\t}\n\t\tinsertRecord(id, value);\n\t\treturn id;\n\t}\n\n\tprivate long writeNewString(String value) throws SQLException {\n\t\tPreparedStatement s = insertStatement.prepareIfNeeded(\n\t\t\t() -> db.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS));\n\t\ts.setString(1, value);\n\t\ts.executeUpdate();\n\t\ttry (ResultSet rs = s.getGeneratedKeys()) {\n\t\t\tif (!rs.next()) {\n\t\t\t\tthrow new SQLException(\"Error during insertion\");\n\t\t\t}\n\t\t\tlong id = rs.getInt(1);\n\t\t\tinsertRecord(id, value);\n\t\t\treturn id;\n\t\t}\n\t}\n\n}\n","sourceCodeStart":243,"sourceCodeEnd":270,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/SQLStringTable.java#L243-L270","documentation":"Thrown by SQLStringTable.writeNewString after inserting a new string row when getGeneratedKeys() returns an empty result set. The string insert succeeded but the driver did not return the auto-generated id, so the new string's id cannot be returned or cached. Same generated-keys class of failure as errors 807/811, applied to the string table.","triggerScenarios":"Calling writeNewString (internally from writeString for a previously-unseen value) on a database/driver that does not support generated keys, or where the stringtable id column is not auto-increment. The single-column insert of the value runs but key retrieval fails.","commonSituations":"JDBC driver/database mode lacking RETURN_GENERATED_KEYS. Stringtable schema without a serial id column. Driver version mismatch. Custom database wrapper that does not propagate generated keys.","solutions":["Ensure the stringtable id column is auto-increment/serial and the driver returns generated keys.","Update the JDBC driver to a compatible version for your database.","Verify the BSim layout created stringtable with an identity id column.","Fall back to a post-insert sequence query if generated keys are unsupported."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify generated-key support before writing strings.\nDatabaseMetaData md = db.getConnection().getMetaData();\nif (!md.supportsGetGeneratedKeys()) {\n    throw new IllegalStateException(\"Driver lacks generated-key support; cannot write new string\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure stringtable id column is auto-increment/serial.","Use a JDBC driver version that returns generated keys.","Validate the BSim layout created an identity id column for stringtable."],"tags":["bsim","database","insert","string-table","generated-keys","jdbc","sql-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}