public void close() throws SQLException { try { queryExecutor.stop(); } catch (Exception e) { e.printStackTrace(); } finally { closed = true; } }
@Override public CachedQuery create(Object key) throws SQLException { assert key instanceof String || key instanceof BaseQueryKey : "Query key should be String or BaseQueryKey. Given " + key.getClass() + ", sql: " + String.valueOf(key); BaseQueryKey queryKey; String parsedSql; if (key instanceof BaseQueryKey) { queryKey = (BaseQueryKey) key; parsedSql = queryKey.sql; } else { queryKey = null; parsedSql = (String) key; } if (key instanceof String || queryKey.escapeProcessing) { parsedSql = Parser.replaceProcessing(parsedSql, true, queryExecutor.getStandardConformingStrings()); } boolean isFunction; boolean outParmBeforeFunc; if (key instanceof CallableQueryKey) { JdbcCallParseInfo callInfo = Parser.modifyJdbcCall( parsedSql, queryExecutor.getStandardConformingStrings(), queryExecutor.getServerVersionNum(), queryExecutor.getProtocolVersion()); parsedSql = callInfo.getSql(); isFunction = callInfo.isFunction(); outParmBeforeFunc = callInfo.isOutParmBeforeFunc(); } else { isFunction = false; outParmBeforeFunc = false; } boolean isParameterized = key instanceof String || queryKey.isParameterized; boolean splitStatements = isParameterized; String[] returningColumns; if (key instanceof QueryWithReturningColumnsKey) { returningColumns = ((QueryWithReturningColumnsKey) key).columnNames; } else { returningColumns = EMPTY_RETURNING; } List<NativeQuery> queries = Parser.parseJdbcSql( parsedSql, queryExecutor.getStandardConformingStrings(), isParameterized, splitStatements, queryExecutor.isReWriteBatchedInsertsEnabled(), returningColumns); Query query = queryExecutor.wrap(queries); return new CachedQuery(key, query, isFunction, outParmBeforeFunc); }
public ResultSet executeQuery(final String query, Map<String, Object> parameters) throws SQLException { if (log.isInfoEnabled()) log.info("Executing query: " + query + "\n with params" + parameters); checkReadOnly(query); try { final ExecutionResult result = queryExecutor.executeQuery(query, parameters); return debug(toResultSet(result)); } catch (Exception e) { throw new SQLException(e); } }
@Override public Boolean call() throws Exception { String reportName = properties.getReportName(); String jobId = queryExecutor.startOozieJob(workflowClient, properties.getOozieProperties()); log.info(String.format("Oozie workflow Id for %s is %s", reportName, jobId)); boolean status = workflowClient.waitForCompletion(jobId); if (!status) { String errorMessage = String.format("%s: Oozie workflow %s failed", reportName, jobId); log.error(errorMessage); } return status; }