public class GenericJdbcDatabaseAccessor extends Object implements DatabaseAccessor
Modifier and Type | Field and Description |
---|---|
protected static String |
DBCP_CONFIG_PREFIX |
protected static org.apache.hadoop.io.Text |
DBCP_PWD |
protected DataSource |
dbcpDataSource |
protected static int |
DEFAULT_FETCH_SIZE |
protected static org.slf4j.Logger |
LOGGER |
Constructor and Description |
---|
GenericJdbcDatabaseAccessor() |
Modifier and Type | Method and Description |
---|---|
protected String |
addLimitAndOffsetToQuery(String sql,
int limit,
int offset)
Uses generic JDBC escape functions to add a limit and offset clause to a query string
|
protected String |
addLimitToQuery(String sql,
int limit) |
protected void |
cleanupResources(Connection conn,
PreparedStatement ps,
ResultSet rs) |
List<String> |
getColumnNames(org.apache.hadoop.conf.Configuration conf) |
protected Properties |
getConnectionPoolProperties(org.apache.hadoop.conf.Configuration conf) |
protected Properties |
getDefaultDBCPProperties() |
protected int |
getFetchSize(org.apache.hadoop.conf.Configuration conf) |
protected String |
getMetaDataQuery(org.apache.hadoop.conf.Configuration conf) |
JdbcRecordIterator |
getRecordIterator(org.apache.hadoop.conf.Configuration conf,
int limit,
int offset) |
int |
getTotalNumberOfRecords(org.apache.hadoop.conf.Configuration conf) |
protected void |
initializeDatabaseConnection(org.apache.hadoop.conf.Configuration conf) |
protected static final String DBCP_CONFIG_PREFIX
protected static final int DEFAULT_FETCH_SIZE
protected static final org.slf4j.Logger LOGGER
protected DataSource dbcpDataSource
protected static final org.apache.hadoop.io.Text DBCP_PWD
public List<String> getColumnNames(org.apache.hadoop.conf.Configuration conf) throws HiveJdbcDatabaseAccessException
getColumnNames
in interface DatabaseAccessor
HiveJdbcDatabaseAccessException
protected String getMetaDataQuery(org.apache.hadoop.conf.Configuration conf)
public int getTotalNumberOfRecords(org.apache.hadoop.conf.Configuration conf) throws HiveJdbcDatabaseAccessException
getTotalNumberOfRecords
in interface DatabaseAccessor
HiveJdbcDatabaseAccessException
public JdbcRecordIterator getRecordIterator(org.apache.hadoop.conf.Configuration conf, int limit, int offset) throws HiveJdbcDatabaseAccessException
getRecordIterator
in interface DatabaseAccessor
HiveJdbcDatabaseAccessException
protected String addLimitAndOffsetToQuery(String sql, int limit, int offset)
sql
- limit
- offset
- protected void cleanupResources(Connection conn, PreparedStatement ps, ResultSet rs)
protected void initializeDatabaseConnection(org.apache.hadoop.conf.Configuration conf) throws Exception
Exception
protected Properties getConnectionPoolProperties(org.apache.hadoop.conf.Configuration conf) throws Exception
Exception
protected Properties getDefaultDBCPProperties()
protected int getFetchSize(org.apache.hadoop.conf.Configuration conf)
Copyright © 2022 The Apache Software Foundation. All rights reserved.