Search in sources :

Example 1 with SqlSelectQuery

use of com.hortonworks.registries.storage.impl.jdbc.provider.sql.query.SqlSelectQuery in project registry by hortonworks.

the class AbstractQueryExecutor method getColumnNames.

@Override
public CaseAgnosticStringSet getColumnNames(String namespace) throws SQLException {
    CaseAgnosticStringSet columns = new CaseAgnosticStringSet();
    Connection connection = null;
    try {
        connection = getConnection();
        final ResultSetMetaData rsMetadata = PreparedStatementBuilder.of(connection, new ExecutionConfig(queryTimeoutSecs), storageDataTypeContext, new SqlSelectQuery(namespace)).getMetaData();
        for (int i = 1; i <= rsMetadata.getColumnCount(); i++) {
            columns.add(rsMetadata.getColumnName(i));
        }
        return columns;
    } catch (SQLException e) {
        log.error(e.getMessage(), e);
        throw new RuntimeException(e);
    } finally {
        if (!transactionBookKeeper.hasActiveTransaction(Thread.currentThread().getId())) {
            closeConnection(connection);
        }
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) CaseAgnosticStringSet(com.hortonworks.registries.storage.impl.jdbc.util.CaseAgnosticStringSet) SqlSelectQuery(com.hortonworks.registries.storage.impl.jdbc.provider.sql.query.SqlSelectQuery) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ExecutionConfig(com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig)

Aggregations

ExecutionConfig (com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig)1 SqlSelectQuery (com.hortonworks.registries.storage.impl.jdbc.provider.sql.query.SqlSelectQuery)1 CaseAgnosticStringSet (com.hortonworks.registries.storage.impl.jdbc.util.CaseAgnosticStringSet)1 Connection (java.sql.Connection)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 SQLException (java.sql.SQLException)1