|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.cloudera.sqoop.manager.ConnManager
com.cloudera.sqoop.manager.SqlManager
public abstract class SqlManager
ConnManager implementation for generic SQL-compliant database. This is an abstract class; it requires a database-specific ConnManager implementation to actually create the connection.
Field Summary | |
---|---|
static org.apache.commons.logging.Log |
LOG
|
protected SqoopOptions |
options
|
Constructor Summary | |
---|---|
SqlManager(SqoopOptions opts)
Constructs the SqlManager. |
Method Summary | |
---|---|
void |
close()
Perform any shutdown operations on the connection. |
void |
execAndPrint(java.lang.String s)
Poor man's SQL query interface; used for debugging. |
protected java.sql.ResultSet |
execute(java.lang.String stmt,
java.lang.Object... args)
Executes an arbitrary SQL statement. |
void |
exportTable(ExportJobContext context)
Export data stored in HDFS into a table in a database. |
protected void |
formatAndPrintResultSet(java.sql.ResultSet results,
java.io.PrintWriter pw)
Prints the contents of a ResultSet to the specified PrintWriter. |
protected java.lang.String |
getColNamesQuery(java.lang.String tableName)
|
protected java.lang.String |
getColTypesQuery(java.lang.String tableName)
|
java.lang.String[] |
getColumnNames(java.lang.String tableName)
Return a list of column names in a table in the order returned by the db. |
java.util.Map<java.lang.String,java.lang.Integer> |
getColumnTypes(java.lang.String tableName)
Return an unordered mapping from colname to sqltype for all columns in a table. |
abstract java.sql.Connection |
getConnection()
Retrieve the actual connection from the outer ConnManager. |
java.lang.String |
getPrimaryKey(java.lang.String tableName)
Return the name of the primary key for a table, or null if there is none. |
protected java.lang.String |
getSplitColumn(SqoopOptions opts,
java.lang.String tableName)
Determine what column to use to split the table. |
void |
importTable(ImportJobContext context)
Default implementation of importTable() is to launch a MapReduce job via DataDrivenImportJob to read the table with DataDrivenDBInputFormat. |
java.lang.String[] |
listDatabases()
Return a list of all databases on a server. |
java.lang.String[] |
listTables()
Return a list of all tables in a database. |
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. |
void |
release()
If a method of this ConnManager has returned a ResultSet to you, you are responsible for calling release() after you close the ResultSet object, to free internal resources. |
java.lang.String |
toHiveType(int sqlType)
Resolve a database-specific type to Hive data 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.ConnManager |
---|
escapeColName, escapeTableName, getDriverClass |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log LOG
protected SqoopOptions options
Constructor Detail |
---|
public SqlManager(SqoopOptions opts)
opts
- the SqoopOptions describing the user's requested action.Method Detail |
---|
protected java.lang.String getColNamesQuery(java.lang.String tableName)
public java.lang.String[] getColumnNames(java.lang.String tableName)
ConnManager
getColumnNames
in class ConnManager
protected java.lang.String getColTypesQuery(java.lang.String tableName)
public java.util.Map<java.lang.String,java.lang.Integer> getColumnTypes(java.lang.String tableName)
ConnManager
getColumnTypes
in class ConnManager
public java.sql.ResultSet readTable(java.lang.String tableName, java.lang.String[] columns) throws java.sql.SQLException
ConnManager
readTable
in class ConnManager
java.sql.SQLException
public java.lang.String[] listDatabases()
ConnManager
listDatabases
in class ConnManager
public java.lang.String[] listTables()
ConnManager
listTables
in class ConnManager
public java.lang.String getPrimaryKey(java.lang.String tableName)
ConnManager
getPrimaryKey
in class ConnManager
public abstract java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in class ConnManager
java.sql.SQLException
protected java.lang.String getSplitColumn(SqoopOptions opts, java.lang.String tableName)
opts
- the SqoopOptions controlling this import.tableName
- the table to import.
public void importTable(ImportJobContext context) throws java.io.IOException, ImportException
importTable
in class ConnManager
java.io.IOException
ImportException
protected java.sql.ResultSet execute(java.lang.String stmt, java.lang.Object... args) throws java.sql.SQLException
stmt
- The SQL statement to execute
java.sql.SQLException
public java.lang.String toJavaType(int sqlType)
toJavaType
in class ConnManager
sqlType
-
public java.lang.String toHiveType(int sqlType)
toHiveType
in class ConnManager
sqlType
- sql type
public void close() throws java.sql.SQLException
ConnManager
close
in class ConnManager
java.sql.SQLException
protected void formatAndPrintResultSet(java.sql.ResultSet results, java.io.PrintWriter pw)
results
- the ResultSet to print.pw
- the location to print the data to.public void execAndPrint(java.lang.String s)
execAndPrint
in class ConnManager
s
- the SQL statement to execute.protected java.sql.Connection makeConnection() throws java.sql.SQLException
java.sql.SQLException
public void exportTable(ExportJobContext context) throws java.io.IOException, ExportException
exportTable
in class ConnManager
java.io.IOException
ExportException
public void release()
ConnManager
release
in class ConnManager
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |