/** * Execute the statements from the parameter that contains the list of StatementHolder in JSon * format * * @param username the user username * @param statementHolderParam the statement request parameter * @param connection the JDBC Connection * @throws SQLException * @throws IOException */ private void executeStatementsFromList( String username, String statementHolderParam, Connection connection) throws SQLException, IOException { List<StatementHolder> statementHolderList = StatementHolderListDecryptor.decryptFromJson(statementHolderParam, commonsConfigurator); ServerBatchStatement serverBatchStatement = new ServerBatchStatement(request, out, sqlConfigurator, connection, username); for (StatementHolder statementHolder : statementHolderList) { String sqlOrder = statementHolder.getSqlOrder(); serverBatchStatement.addBatch(sqlOrder); } serverBatchStatement.executeBatchAndClose(); }
/** * Execute the statements from file name passed in parameter * * @param username the user username * @param fileName the filename containing all the statements in json format, one perline * @param connection the JDBC Connection * @throws SQLException * @throws IOException */ private void executeStatementsFromFile(String username, String fileName, Connection connection) throws SQLException, IOException { fileName = HttpConfigurationUtil.addRootPath(fileConfigurator, username, fileName); File file = new File(fileName); if (!file.exists()) { throw new IOException( Tag.PRODUCT_PRODUCT_FAIL + "The file corresponding to a list of Statements does not exist on remote Server: " + fileName); } StatementHolder statementHolder = null; ServerBatchStatement serverBatchStatement = new ServerBatchStatement(request, out, sqlConfigurator, connection, username); StatementHolderListReader statementHolderListReader = null; try { statementHolderListReader = new StatementHolderListReader(file, commonsConfigurator); while ((statementHolder = statementHolderListReader.readLine()) != null) { String sqlOrder = statementHolder.getSqlOrder(); serverBatchStatement.addBatch(sqlOrder); } serverBatchStatement.executeBatchAndClose(); } finally { if (statementHolderListReader != null) { statementHolderListReader.close(); statementHolderListReader = null; } serverBatchStatement = null; } }