Search in sources :

Example 1 with QueryRunner

use of com.thinkbiganalytics.schema.QueryRunner in project kylo by Teradata.

the class DBCPConnectionPoolService method executeQueryForControllerService.

/**
 * Executes the specified SELECT query in the context of the specified controller service.
 *
 * @param serviceProperties properties describing the data source and the query
 * @return the query results
 * @throws DataAccessException if the query cannot be executed
 */
@Nonnull
private QueryResult executeQueryForControllerService(@Nonnull final PoolingDataSourceService.DataSourceProperties dataSourceProperties, @Nonnull final ExecuteQueryControllerServiceRequest serviceProperties) {
    if (evaluateWithUserDefinedDatasources(dataSourceProperties, serviceProperties)) {
        log.info("Execute query against Controller Service: {} ({}) with uri of {}.  ", serviceProperties.getControllerServiceName(), serviceProperties.getControllerServiceId(), dataSourceProperties.getUrl());
        final DataSource dataSource = PoolingDataSourceService.getDataSource(dataSourceProperties);
        return new QueryRunner(dataSource).query(serviceProperties.getQuery());
    } else {
        throw new DataAccessResourceFailureException("Unable to determine connection properties for controller service: " + serviceProperties.getControllerServiceName() + "(" + serviceProperties.getControllerServiceId() + ")");
    }
}
Also used : DataAccessResourceFailureException(org.springframework.dao.DataAccessResourceFailureException) QueryRunner(com.thinkbiganalytics.schema.QueryRunner) DataSource(javax.sql.DataSource) Nonnull(javax.annotation.Nonnull)

Aggregations

QueryRunner (com.thinkbiganalytics.schema.QueryRunner)1 Nonnull (javax.annotation.Nonnull)1 DataSource (javax.sql.DataSource)1 DataAccessResourceFailureException (org.springframework.dao.DataAccessResourceFailureException)1