com.cloudera.sqoop.manager
Class PostgresqlManager

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.PostgresqlManager
Direct Known Subclasses:
DirectPostgresqlManager

public class PostgresqlManager
extends GenericJdbcManager

Manages connections to Postgresql databases.


Field Summary
static org.apache.commons.logging.Log LOG
           
 
Fields inherited from class com.cloudera.sqoop.manager.SqlManager
options
 
Constructor Summary
  PostgresqlManager(SqoopOptions opts)
           
protected PostgresqlManager(SqoopOptions opts, boolean ignored)
           
 
Method Summary
 void close()
          Perform any shutdown operations on the connection.
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)
           
 java.lang.String getPrimaryKey(java.lang.String tableName)
          Return the name of the primary key for a table, or null if there is none.
 void importTable(ImportJobContext context)
          Default implementation of importTable() is to launch a MapReduce job via DataDrivenImportJob to read the table with DataDrivenDBInputFormat.
 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
discardConnection, getConnection, getDriverClass, hasOpenConnection
 
Methods inherited from class com.cloudera.sqoop.manager.SqlManager
execAndPrint, exportTable, formatAndPrintResultSet, getColTypesQuery, getColumnNames, getColumnTypes, getSplitColumn, listDatabases, listTables, makeConnection, readTable, toHiveType, toJavaType
 
Methods inherited from class com.cloudera.sqoop.manager.ConnManager
escapeColName, escapeTableName
 
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

PostgresqlManager

public PostgresqlManager(SqoopOptions opts)

PostgresqlManager

protected PostgresqlManager(SqoopOptions opts,
                            boolean ignored)
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.

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

getPrimaryKey

public java.lang.String getPrimaryKey(java.lang.String tableName)
Description copied from class: ConnManager
Return the name of the primary key for a table, or null if there is none.

Overrides:
getPrimaryKey in class SqlManager

execute

protected java.sql.ResultSet execute(java.lang.String stmt,
                                     java.lang.Object... args)
                              throws java.sql.SQLException
Executes an arbitrary SQL statement. Sets the cursor fetch size 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

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


Copyright © 2010 Cloudera, Inc.