use of com.thinkbiganalytics.discovery.schema.JdbcSchemaParser in project kylo by Teradata.
the class PostgreSqlSchemaParserTest method prepareDataSourceWithBasicUrl.
/**
* Verify updating data source URL with a catalog name.
*/
@Test
public void prepareDataSourceWithBasicUrl() throws SQLException {
// Test preparing data source with no catalog
DataSourceProperties dataSource = new DataSourceProperties("user", "password", "jdbc:postgresql://localhost:5432");
final JdbcSchemaParser parser = new PostgreSqlSchemaParser();
DataSourceProperties prepared = parser.prepareDataSource(dataSource, null);
Assert.assertNotEquals(dataSource, prepared);
Assert.assertEquals("jdbc:postgresql://localhost:5432/postgres", prepared.getUrl());
// Test preparing data source with user-defined catalog
dataSource = new DataSourceProperties("user", "password", "jdbc:postgresql://localhost:5432?flag=true");
prepared = parser.prepareDataSource(dataSource, "kylo");
Assert.assertNotEquals(dataSource, prepared);
Assert.assertEquals("jdbc:postgresql://localhost:5432/kylo?flag=true", prepared.getUrl());
}
use of com.thinkbiganalytics.discovery.schema.JdbcSchemaParser in project kylo by Teradata.
the class DefaultCatalogTableManager method isolatedFunction.
/**
* Executes the specified function in a separate class loader containing the jars of the specified template.
*/
@VisibleForTesting
protected <R> R isolatedFunction(@Nonnull final DataSetTemplate template, @Nullable final String catalog, @Nonnull final SqlSchemaFunction<R> function) throws SQLException {
// Get Hadoop configuration
final Configuration conf = DataSetUtil.getConfiguration(template, defaultConf);
final HadoopClassLoader classLoader = new HadoopClassLoader(conf);
if (template.getJars() != null) {
log.debug("Adding jars to HadoopClassLoader: {}", template.getJars());
classLoader.addJars(template.getJars());
}
// Get data source configuration
DataSourceProperties properties = getDataSourceProperties(template, classLoader);
final JdbcSchemaParser schemaParser = schemaParserProvider.getSchemaParser(properties.getUrl());
properties = schemaParser.prepareDataSource(properties, catalog);
// Connect to data source
final javax.sql.DataSource dataSource = PoolingDataSourceService.getDataSource(properties);
try (final Connection connection = KerberosUtil.getConnectionWithOrWithoutKerberos(dataSource, new KerberosTicketConfiguration())) {
return function.apply(connection, schemaParser);
}
}
Aggregations