use of eu.esdihumboldt.hale.io.jdbc.JDBCInstanceReader in project hale by halestudio.
the class MsSQLServer14Test method readInstances.
/**
* Reads instances from from a MsAccess database file with the provided
* schema.
*
* @param sourceSchema the schema of the source database
* @return the read instances
* @throws Exception any exception thrown by {@link JDBCInstanceReader}
*/
private InstanceCollection readInstances(Schema sourceSchema) throws Exception {
JDBCInstanceReader instanceReader = new JDBCInstanceReader();
JDBCURI = new MsSqlURIBuilder().createJdbcUri(HOST, DATABASE);
instanceReader.setSource(new NoStreamInputSupplier(JDBCURI));
instanceReader.setSourceSchema(sourceSchema);
instanceReader.setParameter(JDBCInstanceReader.PARAM_USER, Value.of(USER_NAME));
instanceReader.setParameter(JDBCInstanceReader.PARAM_PASSWORD, Value.of(PASSWORD));
// Test instances
IOReport report = instanceReader.execute(new LogProgressIndicator());
assertTrue("Data import was not successfull.", report.isSuccess());
return instanceReader.getInstances();
}
use of eu.esdihumboldt.hale.io.jdbc.JDBCInstanceReader in project hale by halestudio.
the class AbstractDBTest method readInstances.
/**
* Read instances from the database.
*
* @param schema the source schema
* @return the database instances
*
* @throws Exception if reading the instances fails
*/
protected InstanceCollection readInstances(Schema schema) throws Exception {
JDBCInstanceReader reader = new JDBCInstanceReader();
reader.setSource(new NoStreamInputSupplier(jdbcUri));
reader.setParameter(JDBCInstanceWriter.PARAM_USER, Value.of(dbi.getUser()));
reader.setParameter(JDBCInstanceWriter.PARAM_PASSWORD, Value.of(dbi.getPassword()));
DefaultSchemaSpace sourceSchema = new DefaultSchemaSpace();
sourceSchema.addSchema(schema);
reader.setSourceSchema(sourceSchema);
IOReport report = reader.execute(null);
assertTrue(report.isSuccess());
assertTrue(report.getErrors().isEmpty());
return reader.getInstances();
}
use of eu.esdihumboldt.hale.io.jdbc.JDBCInstanceReader in project hale by halestudio.
the class MsSqlDataReaderTest method readInstances.
/**
* Reads instances from from a MsAccess database file with the provided
* schema.
*
* @param sourceSchema the schema of the source database
* @return the read instances
* @throws Exception any exception thrown by {@link JDBCInstanceReader}
*/
private InstanceCollection readInstances(Schema sourceSchema) throws Exception {
JDBCInstanceReader instanceReader = new JDBCInstanceReader();
JDBCURI = new MsSqlURIBuilder().createJdbcUri(HOST, DATABASE);
instanceReader.setSource(new NoStreamInputSupplier(JDBCURI));
instanceReader.setSourceSchema(sourceSchema);
instanceReader.setParameter(JDBCInstanceReader.PARAM_USER, Value.of(USER_NAME));
instanceReader.setParameter(JDBCInstanceReader.PARAM_PASSWORD, Value.of(PASSWORD));
// Test instances
IOReport report = instanceReader.execute(new LogProgressIndicator());
assertTrue("Data import was not successfull.", report.isSuccess());
return instanceReader.getInstances();
}
Aggregations