com.cloudera.sqoop.manager
Class MySQLManager

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.MySQLManager
Direct Known Subclasses:
DirectMySQLManager

public class MySQLManager
extends GenericJdbcManager

Manages connections to MySQL databases.


Field Summary
static org.apache.commons.logging.Log LOG
           
 
Fields inherited from class com.cloudera.sqoop.manager.SqlManager
options
 
Constructor Summary
  MySQLManager(SqoopOptions opts)
           
protected MySQLManager(SqoopOptions opts, boolean ignored)
           
 
Method Summary
 java.lang.String escapeColName(java.lang.String colName)
          When using a column name in a generated SQL query, how (if at all) should we escape that column name? e.g., a column named "table" may need to be quoted with backtiks: "`table`".
 java.lang.String escapeTableName(java.lang.String tableName)
          When using a table name in a generated SQL query, how (if at all) should we escape that column name? e.g., a table named "table" may need to be quoted with backtiks: "`table`".
 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.
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.
 java.lang.String[] listDatabases()
          Return a list of all databases on a server.
protected static void markWarningPrinted()
          Set a flag to prevent printing the --direct warning twice.
 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.
 
Methods inherited from class com.cloudera.sqoop.manager.GenericJdbcManager
close, discardConnection, getConnection, getDriverClass, hasOpenConnection
 
Methods inherited from class com.cloudera.sqoop.manager.SqlManager
exportTable, formatAndPrintResultSet, getColTypesQuery, getColumnNames, getColumnTypes, getPrimaryKey, getSplitColumn, listTables, makeConnection, readTable, toHiveType, toJavaType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

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

MySQLManager

public MySQLManager(SqoopOptions opts)

MySQLManager

protected MySQLManager(SqoopOptions opts,
                       boolean ignored)
Method Detail

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.

listDatabases

public java.lang.String[] listDatabases()
Description copied from class: ConnManager
Return a list of all databases on a server.

Overrides:
listDatabases in class SqlManager

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

markWarningPrinted

protected static void markWarningPrinted()
Set a flag to prevent printing the --direct warning twice.


execute

protected java.sql.ResultSet execute(java.lang.String stmt,
                                     java.lang.Object... args)
                              throws java.sql.SQLException
Executes an arbitrary SQL statement. Sets mysql-specific parameter to ensure the entire table is not buffered in RAM before reading any rows. A consequence of this is that every ResultSet returned by this method *MUST* be close()'d, or read to exhaustion before another query can be executed from this ConnManager instance.

Overrides:
execute in class SqlManager
Parameters:
stmt - The SQL statement to execute
Returns:
A ResultSet encapsulating the results or null on error
Throws:
java.sql.SQLException

execAndPrint

public void execAndPrint(java.lang.String s)
Description copied from class: SqlManager
Poor man's SQL query interface; used for debugging.

Overrides:
execAndPrint in class SqlManager
Parameters:
s - the SQL statement to execute.

release

public void release()
Description copied from class: ConnManager
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. ConnManager implementations do not guarantee the ability to have multiple returned ResultSets available concurrently. Requesting a new ResultSet from a ConnManager may cause other open ResulSets to close.

Overrides:
release in class SqlManager

escapeColName

public java.lang.String escapeColName(java.lang.String colName)
When using a column name in a generated SQL query, how (if at all) should we escape that column name? e.g., a column named "table" may need to be quoted with backtiks: "`table`".

Overrides:
escapeColName in class ConnManager
Parameters:
colName - the column name as provided by the user, etc.
Returns:
how the column name should be rendered in the sql text.

escapeTableName

public java.lang.String escapeTableName(java.lang.String tableName)
When using a table name in a generated SQL query, how (if at all) should we escape that column name? e.g., a table named "table" may need to be quoted with backtiks: "`table`".

Overrides:
escapeTableName in class ConnManager
Parameters:
tableName - the table name as provided by the user, etc.
Returns:
how the table name should be rendered in the sql text.


Copyright © 2010 Cloudera, Inc.