private boolean writeToTable(Object[] rowData) throws KettleValueException { if (rowData == null) // Stop: last line or error encountered { if (log.isDetailed()) { logDetailed("Last line inserted: stop"); } return false; } if (first) { first = false; data.outputRowMeta = getInputRowMeta(); // First open or create the table try { String realTablename = environmentSubstitute(meta.getTablename()); data.table = data.db.getTable(realTablename); if (data.table == null) { if (meta.isTableCreated()) { // Create the table data.columns = AccessOutputMeta.getColumns(data.outputRowMeta); data.db.createTable(realTablename, data.columns); data.table = data.db.getTable(realTablename); } else { logError( BaseMessages.getString(PKG, "AccessOutput.Error.TableDoesNotExist", realTablename)); setErrors(1); stopAll(); return false; } } // All OK: we have an open database and a table to write to. // // Apparently it's not yet possible to remove rows from the table // So truncate is out for the moment as well. } catch (Exception e) { logError( BaseMessages.getString( PKG, "AccessOutput.Exception.UnexpectedErrorCreatingTable", e.toString())); logError(Const.getStackTracker(e)); setErrors(1); stopAll(); return false; } } // Let's write a row to the database. Object[] columnValues = AccessOutputMeta.createObjectsForRow(data.outputRowMeta, rowData); try { data.rows.add(columnValues); if (meta.getCommitSize() > 0) { if (data.rows.size() >= meta.getCommitSize()) { data.table.addRows(data.rows); data.rows.clear(); } } else { data.table.addRow(columnValues); } } catch (IOException e) { logError( BaseMessages.getString( PKG, "AccessOutput.Exception.UnexpectedErrorWritingRow", data.outputRowMeta.getString(rowData))); logError(Const.getStackTracker(e)); setErrors(1); stopAll(); return false; } return true; }