public class JdbcDataSource extends DataSource<Iterator<Map<String,Object>>>
A DataSource implementation which can fetch data using JDBC.
Refer to http://wiki.apache.org/solr/DataImportHandler for more details.
This API is experimental and may change in the future.
Modifier and Type | Class and Description |
---|---|
protected class |
JdbcDataSource.ResultSetIterator |
Modifier and Type | Field and Description |
---|---|
static String |
CONVERT_TYPE |
static String |
DRIVER |
protected Callable<Connection> |
factory |
static String |
JNDI_NAME |
static String |
URL |
Constructor and Description |
---|
JdbcDataSource() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Cleans up resources of this DataSource after use.
|
protected Callable<Connection> |
createConnectionFactory(Context context,
Properties initProps) |
protected JdbcDataSource.ResultSetIterator |
createResultSetIterator(String query) |
protected void |
finalize() |
protected Connection |
getConnection() |
Iterator<Map<String,Object>> |
getData(String query)
Get records for the given query.The return type depends on the
implementation .
|
void |
init(Context context,
Properties initProps)
Initializes the DataSource with the
Context and
initialization properties. |
protected List<String> |
readFieldNames(ResultSetMetaData metaData) |
protected Callable<Connection> factory
public static final String URL
public static final String JNDI_NAME
public static final String DRIVER
public static final String CONVERT_TYPE
public void init(Context context, Properties initProps)
DataSource
Context
and
initialization properties.
This is invoked by the DataImporter
after creating an
instance of this class.
protected Callable<Connection> createConnectionFactory(Context context, Properties initProps)
public Iterator<Map<String,Object>> getData(String query)
DataSource
getData
in class DataSource<Iterator<Map<String,Object>>>
query
- The query string. It can be a SQL for JdbcDataSource or a URL
for HttpDataSource or a file location for FileDataSource or a custom
format for your own custom DataSource.protected JdbcDataSource.ResultSetIterator createResultSetIterator(String query)
protected List<String> readFieldNames(ResultSetMetaData metaData) throws SQLException
SQLException
protected Connection getConnection() throws Exception
Exception
protected void finalize() throws Throwable
public void close()
DataSource
close
in interface Closeable
close
in interface AutoCloseable
close
in class DataSource<Iterator<Map<String,Object>>>
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.