public class SQLDataSource<T extends Output<T>> extends ColumnarDataSource<T> implements AutoCloseable
DataSource
for loading columnar data from a database
and applying FieldProcessor
s to it.
The Connection
s it creates are closed when the iterator is empty
(ie. when hasNext is called and returns false). Calling close() on SQLDatasource itself closes all connections
created since close was last called.
N.B. This class accepts raw SQL strings and executes them directly via JDBC. It DOES NOT perform any SQL escaping or other injection prevention. It is the user's responsibility to ensure that SQL passed to this class performs as desired.
Modifier and Type | Class and Description |
---|---|
static class |
SQLDataSource.SQLDataSourceProvenance
Provenance for
SQLDataSource . |
outputRequired, rowProcessor
Constructor and Description |
---|
SQLDataSource(String sqlString,
SQLDBConfig sqlConfig,
OutputFactory<T> outputFactory,
RowProcessor<T> rowProcessor,
boolean outputRequired) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
ConfiguredDataSourceProvenance |
getProvenance() |
ColumnarIterator |
rowIterator()
The iterator that emits
ColumnarIterator.Row objects from the
underlying data source. |
String |
toString() |
getMetadataTypes, getOutputFactory, iterator
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public SQLDataSource(String sqlString, SQLDBConfig sqlConfig, OutputFactory<T> outputFactory, RowProcessor<T> rowProcessor, boolean outputRequired) throws SQLException
SQLException
public ColumnarIterator rowIterator()
ColumnarDataSource
ColumnarIterator.Row
objects from the
underlying data source.rowIterator
in class ColumnarDataSource<T extends Output<T>>
public void close()
close
in interface AutoCloseable
public ConfiguredDataSourceProvenance getProvenance()
getProvenance
in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<DataSourceProvenance>
Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.