use of com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig in project registry by hortonworks.
the class MySqlStorageManagerNoCacheIntegrationTest method setFields.
private void setFields(ConnectionBuilder connectionBuilder, Database db) {
JdbcStorageManagerIntegrationTest.connectionBuilder = connectionBuilder;
jdbcStorageManager = createJdbcStorageManager(new MySqlExecutor(new ExecutionConfig(-1), connectionBuilder));
database = db;
}
use of com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig 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);
}
}
}
use of com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig in project registry by hortonworks.
the class OracleExecutor 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), ORACLE_DATA_TYPE_CONTEXT, new OracleSelectQuery(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);
}
}
}
use of com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig in project registry by hortonworks.
the class OracleSequenceIdQuery method getNextID.
public Long getNextID(Connection connection) {
OracleSqlQuery nextValueQuery = new OracleSqlQuery(String.format("SELECT \"%s\".%s from DUAL", namespace.toUpperCase(), nextValueFunction));
Long nextId = 0l;
try {
ResultSet selectResultSet = PreparedStatementBuilder.of(connection, new ExecutionConfig(queryTimeoutSecs), oracleDatabaseStorageContext, nextValueQuery).getPreparedStatement(nextValueQuery).executeQuery();
if (selectResultSet.next()) {
nextId = selectResultSet.getLong(nextValueFunction);
} else {
throw new RuntimeException("No sequence-id created for the current sequence of [" + namespace + "]");
}
log.debug("Generated sequence id [{}] for [{}]", nextId, namespace);
} catch (SQLException e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e);
}
return nextId;
}
use of com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig in project registry by hortonworks.
the class QueryExecutorFactory method get.
public static QueryExecutor get(String type, Map<String, Object> dbProperties) {
HikariCPConnectionBuilder connectionBuilder = getHikariCPConnnectionBuilder(dbProperties);
ExecutionConfig executionConfig = getExecutionConfig(dbProperties);
QueryExecutor queryExecutor = null;
switch(type) {
case "mysql":
queryExecutor = new MySqlExecutor(executionConfig, connectionBuilder);
break;
case "postgresql":
queryExecutor = new PostgresqlExecutor(executionConfig, connectionBuilder);
break;
case "oracle":
queryExecutor = new OracleExecutor(executionConfig, connectionBuilder);
break;
default:
throw new IllegalArgumentException("Unsupported storage provider type: " + type);
}
return queryExecutor;
}
Aggregations