use of eu.esdihumboldt.hale.io.jdbc.SQLSchemaReader in project hale by halestudio.
the class AbstractDBTest method readSchema.
/**
* Load the database schema for a SQL statement.
*
* @param sql the SQL query
* @param typeName the type name for the query
*
* @return the schema
* @throws Exception if reading the schema fails
*/
protected Schema readSchema(String sql, String typeName) throws Exception {
SQLSchemaReader schemaReader = new SQLSchemaReader();
schemaReader.setSource(new NoStreamInputSupplier(jdbcUri));
schemaReader.setParameter(JDBCSchemaReader.PARAM_USER, Value.of(dbi.getUser()));
schemaReader.setParameter(JDBCSchemaReader.PARAM_PASSWORD, Value.of(dbi.getPassword()));
schemaReader.setParameter(SQLSchemaReader.PARAM_SQL, Value.of(sql));
schemaReader.setParameter(SQLSchemaReader.PARAM_TYPE_NAME, Value.of(typeName));
IOReport report = schemaReader.execute(null);
assertTrue(report.isSuccess());
assertTrue(report.getErrors().isEmpty());
Schema schema = schemaReader.getSchema();
assertNotNull(schema);
return schema;
}
Aggregations