use of eu.esdihumboldt.hale.io.jdbc.JDBCInstanceWriter in project hale by halestudio.
the class AbstractDBTest method writeInstances.
/**
* Write instances to the database.
*
* @param instances the collection of instances
* @param schema the target schema
* @throws Exception if writing the instances fails
*/
protected void writeInstances(InstanceCollection instances, Schema schema) throws Exception {
JDBCInstanceWriter writer = new JDBCInstanceWriter();
writer.setTarget(new NoStreamOutputSupplier(jdbcUri));
writer.setParameter(JDBCInstanceWriter.PARAM_USER, Value.of(dbi.getUser()));
writer.setParameter(JDBCInstanceWriter.PARAM_PASSWORD, Value.of(dbi.getPassword()));
writer.setInstances(instances);
DefaultSchemaSpace targetSchema = new DefaultSchemaSpace();
targetSchema.addSchema(schema);
writer.setTargetSchema(targetSchema);
IOReport report = writer.execute(null);
assertTrue(report.isSuccess());
assertTrue(report.getErrors().isEmpty());
}
Aggregations