org.apache.hadoop.mapreduce.lib.db
Class DBConfiguration

java.lang.Object
  extended by org.apache.hadoop.mapreduce.lib.db.DBConfiguration
Direct Known Subclasses:
DBConfiguration

@InterfaceAudience.Public
@InterfaceStability.Stable
public class DBConfiguration
extends Object

A container for configuration property names for jobs with DB input/output. The job can be configured using the static methods in this class, DBInputFormat, and DBOutputFormat. Alternatively, the properties can be set in the configuration with proper values.

See Also:
configureDB(Configuration, String, String, String, String), DBInputFormat.setInput(Job, Class, String, String), DBInputFormat.setInput(Job, Class, String, String, String, String...), DBOutputFormat.setOutput(Job, String, String...)

Field Summary
static String DRIVER_CLASS_PROPERTY
          The JDBC Driver class name
static String INPUT_BOUNDING_QUERY
          Input query to get the max and min values of the jdbc.input.query
static String INPUT_CLASS_PROPERTY
          Class name implementing DBWritable which will hold input tuples
static String INPUT_CONDITIONS_PROPERTY
          WHERE clause in the input SELECT statement
static String INPUT_COUNT_QUERY
          Input query to get the count of records
static String INPUT_FIELD_NAMES_PROPERTY
          Field names in the Input table
static String INPUT_ORDER_BY_PROPERTY
          ORDER BY clause in the input SELECT statement
static String INPUT_QUERY
          Whole input query, exluding LIMIT...OFFSET
static String INPUT_TABLE_NAME_PROPERTY
          Input table name
static String OUTPUT_FIELD_COUNT_PROPERTY
          Number of fields in the Output table
static String OUTPUT_FIELD_NAMES_PROPERTY
          Field names in the Output table
static String OUTPUT_TABLE_NAME_PROPERTY
          Output table name
static String PASSWORD_PROPERTY
          Password to access the database
static String URL_PROPERTY
          JDBC Database access URL
static String USERNAME_PROPERTY
          User name to access the database
 
Constructor Summary
DBConfiguration(Configuration job)
           
 
Method Summary
static void configureDB(Configuration job, String driverClass, String dbUrl)
          Sets the DB access related fields in the JobConf.
static void configureDB(Configuration conf, String driverClass, String dbUrl, String userName, String passwd)
          Sets the DB access related fields in the Configuration.
 Configuration getConf()
           
 Connection getConnection()
          Returns a connection object o the DB
 String getInputBoundingQuery()
           
 Class<?> getInputClass()
           
 String getInputConditions()
           
 String getInputCountQuery()
           
 String[] getInputFieldNames()
           
 String getInputOrderBy()
           
 String getInputQuery()
           
 String getInputTableName()
           
 int getOutputFieldCount()
           
 String[] getOutputFieldNames()
           
 String getOutputTableName()
           
 void setInputBoundingQuery(String query)
           
 void setInputClass(Class<? extends DBWritable> inputClass)
           
 void setInputConditions(String conditions)
           
 void setInputCountQuery(String query)
           
 void setInputFieldNames(String... fieldNames)
           
 void setInputOrderBy(String orderby)
           
 void setInputQuery(String query)
           
 void setInputTableName(String tableName)
           
 void setOutputFieldCount(int fieldCount)
           
 void setOutputFieldNames(String... fieldNames)
           
 void setOutputTableName(String tableName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DRIVER_CLASS_PROPERTY

public static final String DRIVER_CLASS_PROPERTY
The JDBC Driver class name

See Also:
Constant Field Values

URL_PROPERTY

public static final String URL_PROPERTY
JDBC Database access URL

See Also:
Constant Field Values

USERNAME_PROPERTY

public static final String USERNAME_PROPERTY
User name to access the database

See Also:
Constant Field Values

PASSWORD_PROPERTY

public static final String PASSWORD_PROPERTY
Password to access the database

See Also:
Constant Field Values

INPUT_TABLE_NAME_PROPERTY

public static final String INPUT_TABLE_NAME_PROPERTY
Input table name

See Also:
Constant Field Values

INPUT_FIELD_NAMES_PROPERTY

public static final String INPUT_FIELD_NAMES_PROPERTY
Field names in the Input table

See Also:
Constant Field Values

INPUT_CONDITIONS_PROPERTY

public static final String INPUT_CONDITIONS_PROPERTY
WHERE clause in the input SELECT statement

See Also:
Constant Field Values

INPUT_ORDER_BY_PROPERTY

public static final String INPUT_ORDER_BY_PROPERTY
ORDER BY clause in the input SELECT statement

See Also:
Constant Field Values

INPUT_QUERY

public static final String INPUT_QUERY
Whole input query, exluding LIMIT...OFFSET

See Also:
Constant Field Values

INPUT_COUNT_QUERY

public static final String INPUT_COUNT_QUERY
Input query to get the count of records

See Also:
Constant Field Values

INPUT_BOUNDING_QUERY

public static final String INPUT_BOUNDING_QUERY
Input query to get the max and min values of the jdbc.input.query

See Also:
Constant Field Values

INPUT_CLASS_PROPERTY

public static final String INPUT_CLASS_PROPERTY
Class name implementing DBWritable which will hold input tuples

See Also:
Constant Field Values

OUTPUT_TABLE_NAME_PROPERTY

public static final String OUTPUT_TABLE_NAME_PROPERTY
Output table name

See Also:
Constant Field Values

OUTPUT_FIELD_NAMES_PROPERTY

public static final String OUTPUT_FIELD_NAMES_PROPERTY
Field names in the Output table

See Also:
Constant Field Values

OUTPUT_FIELD_COUNT_PROPERTY

public static final String OUTPUT_FIELD_COUNT_PROPERTY
Number of fields in the Output table

See Also:
Constant Field Values
Constructor Detail

DBConfiguration

public DBConfiguration(Configuration job)
Method Detail

configureDB

public static void configureDB(Configuration conf,
                               String driverClass,
                               String dbUrl,
                               String userName,
                               String passwd)
Sets the DB access related fields in the Configuration.

Parameters:
conf - the configuration
driverClass - JDBC Driver class name
dbUrl - JDBC DB access URL.
userName - DB access username
passwd - DB access passwd

configureDB

public static void configureDB(Configuration job,
                               String driverClass,
                               String dbUrl)
Sets the DB access related fields in the JobConf.

Parameters:
job - the job
driverClass - JDBC Driver class name
dbUrl - JDBC DB access URL.

getConnection

public Connection getConnection()
                         throws ClassNotFoundException,
                                SQLException
Returns a connection object o the DB

Throws:
ClassNotFoundException
SQLException

getConf

public Configuration getConf()

getInputTableName

public String getInputTableName()

setInputTableName

public void setInputTableName(String tableName)

getInputFieldNames

public String[] getInputFieldNames()

setInputFieldNames

public void setInputFieldNames(String... fieldNames)

getInputConditions

public String getInputConditions()

setInputConditions

public void setInputConditions(String conditions)

getInputOrderBy

public String getInputOrderBy()

setInputOrderBy

public void setInputOrderBy(String orderby)

getInputQuery

public String getInputQuery()

setInputQuery

public void setInputQuery(String query)

getInputCountQuery

public String getInputCountQuery()

setInputCountQuery

public void setInputCountQuery(String query)

setInputBoundingQuery

public void setInputBoundingQuery(String query)

getInputBoundingQuery

public String getInputBoundingQuery()

getInputClass

public Class<?> getInputClass()

setInputClass

public void setInputClass(Class<? extends DBWritable> inputClass)

getOutputTableName

public String getOutputTableName()

setOutputTableName

public void setOutputTableName(String tableName)

getOutputFieldNames

public String[] getOutputFieldNames()

setOutputFieldNames

public void setOutputFieldNames(String... fieldNames)

setOutputFieldCount

public void setOutputFieldCount(int fieldCount)

getOutputFieldCount

public int getOutputFieldCount()


Copyright © 2012 Apache Software Foundation. All Rights Reserved.