{"record":{"id":"36209cf3f011c9a5","repo":"pentaho/pentaho-kettle","slug":"unexpected-error-inserting-row-tableoutput","errorCode":null,"errorMessage":"Unexpected error inserting row","messagePattern":"Unexpected error inserting row","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java","lineNumber":295,"sourceCode":"      if ( data.useSafePoints ) {\n        if ( data.releaseSavepoint ) {\n          data.db.releaseSavepoint( data.savepoint );\n        }\n      }\n\n      // Perform a commit if needed\n      //\n\n      if ( ( data.commitSize > 0 ) && ( ( commitCounter % data.commitSize ) == 0 ) ) {\n        if ( data.db.getUseBatchInsert( data.batchMode ) ) {\n          try {\n            insertStatement.executeBatch();\n            data.db.commit();\n            insertStatement.clearBatch();\n          } catch ( SQLException ex ) {\n            throw Database.createKettleDatabaseBatchException( \"Error updating batch\", ex );\n          } catch ( Exception ex ) {\n            throw new KettleDatabaseException( \"Unexpected error inserting row\", ex );\n          }\n        } else {\n          // insertRow normal commit\n          data.db.commit();\n        }\n        // Clear the batch/commit counter...\n        //\n        data.commitCounterMap.put( tableName, Integer.valueOf( 0 ) );\n        rowIsSafe = true;\n      } else {\n        rowIsSafe = false;\n      }\n\n      // See if we need to get back the keys as well...\n      if ( meta.isReturningGeneratedKeys() ) {\n        RowMetaAndData extraKeys = data.db.getGeneratedKeys( insertStatement );\n\n        if ( extraKeys.getRowMeta().size() > 0 ) {","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java#L277-L313","documentation":"The generic catch-all in the batch flush path: any non-SQLException exception thrown during executeBatch()/commit()/clearBatch() is wrapped in a KettleDatabaseException with this message. It signals an unexpected (usually runtime) failure rather than a plain JDBC SQL error.","triggerScenarios":"A RuntimeException or driver-specific non-SQLException is thrown from insertStatement.executeBatch(), data.db.commit(), or clearBatch() while batch inserting in writeToTable.","commonSituations":"JDBC driver bugs or driver class version mismatches; connection closed by another thread; OutOfMemoryError handling large batches; misconfigured Kettle database connection object.","solutions":["Read the cause chain of the KettleDatabaseException to find the underlying runtime error.","Update the JDBC driver to a version compatible with the database and Pentaho/Kettle version.","Reduce commit/batch size to lower memory pressure.","If the connection was closed, check for concurrent use of the same database connection across steps."],"exampleFix":"// before: commit size 100000 causing OOM with huge rows\n// after: set 'Commit size' to 1000 in the TableOutput dialog","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  insertStatement.executeBatch();\n} catch ( KettleDatabaseException e ) {\n  Throwable cause = e.getCause();\n  log.error( \"Unexpected batch failure\", cause ); // inspect cause for driver/runtime issue\n  data.db.rollback();\n}","preventionTips":["Keep the JDBC driver version aligned with both the DB server and the Pentaho version","Avoid oversized commit sizes that can exhaust memory","Never share one database connection across concurrent steps/threads"],"tags":["kettle","table-output","jdbc","batch","unexpected-error"],"backgroundTag":"database-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}