com.cloudera.sqoop.manager
Class OracleManager

java.lang.Object
  extended by com.cloudera.sqoop.manager.ConnManager
      extended by com.cloudera.sqoop.manager.SqlManager
          extended by com.cloudera.sqoop.manager.GenericJdbcManager
              extended by com.cloudera.sqoop.manager.OracleManager

public class OracleManager
extends GenericJdbcManager

Manages connections to Oracle databases. Requires the Oracle JDBC driver.


Field Summary
static org.apache.commons.logging.Log LOG
           
static java.lang.String ORACLE_TIMEZONE_KEY
           
 
Fields inherited from class com.cloudera.sqoop.manager.SqlManager
options
 
Constructor Summary
OracleManager(SqoopOptions opts)
           
 
Method Summary
 void close()
          Perform any shutdown operations on the connection.
 void exportTable(ExportJobContext context)
          Export data stored in HDFS into a table in a database.
protected  void finalize()
           
protected  java.lang.String getColNamesQuery(java.lang.String tableName)
           
 void importTable(ImportJobContext context)
          Default implementation of importTable() is to launch a MapReduce job via DataDrivenImportJob to read the table with DataDrivenDBInputFormat.
protected  java.sql.Connection makeConnection()
          Create a connection to the database; usually used only from within getConnection(), which enforces a singleton guarantee around the Connection object.
 java.sql.ResultSet readTable(java.lang.String tableName, java.lang.String[] columns)
          Execute a SQL statement to read the named set of columns from a table.
 java.lang.String toHiveType(int sqlType)
          Attempt to map sql type to hive type.
 java.lang.String toJavaType(int sqlType)
          Resolve a database-specific type to the Java type that should contain it.
 
Methods inherited from class com.cloudera.sqoop.manager.GenericJdbcManager
discardConnection, getConnection, getDriverClass, hasOpenConnection
 
Methods inherited from class com.cloudera.sqoop.manager.SqlManager
execAndPrint, execute, formatAndPrintResultSet, getColTypesQuery, getColumnNames, getColumnTypes, getPrimaryKey, getSplitColumn, listDatabases, listTables, release
 
Methods inherited from class com.cloudera.sqoop.manager.ConnManager
escapeColName, escapeTableName
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

ORACLE_TIMEZONE_KEY

public static final java.lang.String ORACLE_TIMEZONE_KEY
See Also:
Constant Field Values
Constructor Detail

OracleManager

public OracleManager(SqoopOptions opts)
Method Detail

close

public void close()
           throws java.sql.SQLException
Description copied from class: ConnManager
Perform any shutdown operations on the connection.

Overrides:
close in class GenericJdbcManager
Throws:
java.sql.SQLException

getColNamesQuery

protected java.lang.String getColNamesQuery(java.lang.String tableName)
Overrides:
getColNamesQuery in class SqlManager
Returns:
the SQL query to use in getColumnNames() in case this logic must be tuned per-database, but the main extraction loop is still inheritable.

makeConnection

protected java.sql.Connection makeConnection()
                                      throws java.sql.SQLException
Create a connection to the database; usually used only from within getConnection(), which enforces a singleton guarantee around the Connection object. Oracle-specific driver uses READ_COMMITTED which is the weakest semantics Oracle supports.

Overrides:
makeConnection in class SqlManager
Throws:
java.sql.SQLException

importTable

public void importTable(ImportJobContext context)
                 throws java.io.IOException,
                        ImportException
Description copied from class: SqlManager
Default implementation of importTable() is to launch a MapReduce job via DataDrivenImportJob to read the table with DataDrivenDBInputFormat.

Overrides:
importTable in class SqlManager
Throws:
java.io.IOException
ImportException

exportTable

public void exportTable(ExportJobContext context)
                 throws java.io.IOException,
                        ExportException
Export data stored in HDFS into a table in a database.

Overrides:
exportTable in class SqlManager
Throws:
java.io.IOException
ExportException

readTable

public java.sql.ResultSet readTable(java.lang.String tableName,
                                    java.lang.String[] columns)
                             throws java.sql.SQLException
Description copied from class: ConnManager
Execute a SQL statement to read the named set of columns from a table. If columns is null, all columns from the table are read. This is a direct (non-parallelized) read of the table back to the current client. The client is responsible for calling ResultSet.close() when done with the returned ResultSet object, and for calling release() after that to free internal state.

Overrides:
readTable in class SqlManager
Throws:
java.sql.SQLException

toJavaType

public java.lang.String toJavaType(int sqlType)
Resolve a database-specific type to the Java type that should contain it.

Overrides:
toJavaType in class SqlManager
Parameters:
sqlType -
Returns:
the name of a Java type to hold the sql datatype, or null if none.

toHiveType

public java.lang.String toHiveType(int sqlType)
Attempt to map sql type to hive type.

Overrides:
toHiveType in class SqlManager
Parameters:
sqlType - sql data type
Returns:
hive data type

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable


Copyright © 2010 Cloudera, Inc.