Class JdbcDataSource
- java.lang.Object
-
- org.apache.solr.handler.dataimport.DataSource<Iterator<Map<String,Object>>>
-
- org.apache.solr.handler.dataimport.JdbcDataSource
-
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.
- Since:
- solr 1.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJdbcDataSource.ResultSetIterator
-
Constructor Summary
Constructors Constructor Description JdbcDataSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Cleans up resources of this DataSource after use.protected Callable<Connection>createConnectionFactory(Context context, Properties initProps)protected JdbcDataSource.ResultSetIteratorcreateResultSetIterator(String query)protected voidfinalize()protected ConnectiongetConnection()Iterator<Map<String,Object>>getData(String query)Get records for the given query.The return type depends on the implementation .voidinit(Context context, Properties initProps)Initializes the DataSource with theContextand initialization properties.protected List<String>readFieldNames(ResultSetMetaData metaData)
-
-
-
Field Detail
-
factory
protected Callable<Connection> factory
-
URL
public static final String URL
- See Also:
- Constant Field Values
-
JNDI_NAME
public static final String JNDI_NAME
- See Also:
- Constant Field Values
-
DRIVER
public static final String DRIVER
- See Also:
- Constant Field Values
-
CONVERT_TYPE
public static final String CONVERT_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(Context context, Properties initProps)
Description copied from class:DataSourceInitializes the DataSource with theContextand initialization properties.This is invoked by the
DataImporterafter creating an instance of this class.
-
createConnectionFactory
protected Callable<Connection> createConnectionFactory(Context context, Properties initProps)
-
getData
public Iterator<Map<String,Object>> getData(String query)
Description copied from class:DataSourceGet records for the given query.The return type depends on the implementation .- Specified by:
getDatain classDataSource<Iterator<Map<String,Object>>>- Parameters:
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.- Returns:
- Depends on the implementation. For instance JdbcDataSource returns an Iterator<Map <String,Object>>
-
createResultSetIterator
protected JdbcDataSource.ResultSetIterator createResultSetIterator(String query)
-
readFieldNames
protected List<String> readFieldNames(ResultSetMetaData metaData) throws SQLException
- Throws:
SQLException
-
getConnection
protected Connection getConnection() throws Exception
- Throws:
Exception
-
finalize
protected void finalize() throws Throwable
-
close
public void close()
Description copied from class:DataSourceCleans up resources of this DataSource after use.
-
-