public void insert() throws Exception { Connection connection = null; try { connection = getConnection(); List<String[]> records = TableDataReader.readRecords(new ByteArrayInputStream(content)); insertRecords(connection, records, tableName); } finally { closeConnection(connection); } }
TableImporter tableDataInserter = new TableImporter(dataSource, buff.toString().getBytes(), tableName); tableDataInserter.insert();
int columnsCount = records.get(0).length; PreparedStatement insertStatement = connection .prepareStatement(INSERT_INTO + tableName + VALUES + generateQM(columnsCount) + CLOSE);
/** * Process the data rows in the 'replace' mode * * @param model * the model * @throws Exception * in case of database error */ public void executeReplaceUpdate(DataStructureDataReplaceModel model) throws Exception { logger.info("Processing rows in mode 'replace': " + model.getLocation()); String tableName = model.getName(); deleteAllDataFromTable(tableName); byte[] content = model.getContent().getBytes(); if (content.length != 0) { TableImporter tableDataInserter = new TableImporter(dataSource, content, tableName); tableDataInserter.insert(); moveSequence(tableName); // move the sequence just in case } }
/** * Process the data rows in the 'append' mode * * @param model * the model * @throws Exception * in case of database error */ public void executeAppendUpdate(DataStructureDataAppendModel model) throws Exception { logger.info("Processing rows in mode 'append': " + model.getLocation()); String tableName = model.getName(); int tableRowsCount = getTableRowsCount(tableName); if (tableRowsCount == 0) { byte[] content = model.getContent().getBytes(); if (content.length != 0) { TableImporter tableDataInserter = new TableImporter(dataSource, content, tableName); tableDataInserter.insert(); moveSequence(tableName); // move the sequence, to be able to add more records after the initial import } } }