net.sf.farrago.syslib
Class FarragoExportSchemaUDR

java.lang.Object
  extended by net.sf.farrago.syslib.FarragoExportSchemaUDR

public abstract class FarragoExportSchemaUDR
extends Object

FarragoExportSchemaUDR provides system procedures to export tables from a local or foreign schema into CSV files.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/syslib/FarragoExportSchemaUDR.java#19 $
Author:
Elizabeth Lin

Field Summary
private static String[] EXPORT_TYPES
           
private static int FULL_EXPORT
           
private static int INCR_EXPORT
           
private static String LOGFILE_PREFIX
           
private static int MERGE_EXPORT
           
private static String NEWLINE
           
private static String QUOTE
           
private static String TAB
           
private static String[] TABLE_TYPES
           
private static Logger tracer
           
 
Constructor Summary
FarragoExportSchemaUDR()
           
 
Method Summary
private static String buildImportForeignSchemaSql(String foreignServer, String foreignSchema, String tableList, String tablePattern, boolean exclude, String tempSchema)
          Helper function to build the import foreign schema SQL used in exporting from a foreign schema
private static String buildQuerySql(int expType, String catalog, String schema, String tblName, Timestamp lastModifiedTs, String colName, String incrCatalog, String incrSchema)
          Helper function to build sql to query tables
private static int checkColumnName(int expType, String catalog, String schema, String incrCatalog, String incrSchema, String tableName, String columnName, Connection conn)
          Checks the column names passed in are valid for a table; last modified column for incremental export and id column for merge export
private static void exportForeignSchemaHelper(int expType, String foreignServer, String foreignSchema, boolean exclude, String tableList, String tablePattern, Timestamp lastModified, String lastModifiedColumn, String directory, boolean withBcp, boolean deleteFailedFiles)
          Helper function for full and incremental exports of tables within a foreign schema
static void exportForeignSchemaIncrementalToCsv(String foreignServer, String foreignSchema, boolean exclude, String tableList, String tablePattern, Timestamp lastModified, String lastModifiedColumn, String directory)
          Standard version of incremental foreign schema export which always creates bcp files and deletes any leftover files from failed table exports
static void exportForeignSchemaIncrementalToCsv(String foreignServer, String foreignSchema, boolean exclude, String tableList, String tablePattern, Timestamp lastModified, String lastModifiedColumn, String directory, boolean withBcp, boolean deleteFailedFiles)
          Exports tables within a foreign schema to CSV/BCP files for rows modified after a specified timestamp
static void exportForeignSchemaToCsv(String foreignServer, String foreignSchema, boolean exclude, String tableList, String tablePattern, String directory)
          Standard version of foreign schema export which always creates bcp files and deletes any leftover files from failed table exports
static void exportForeignSchemaToCsv(String foreignServer, String foreignSchema, boolean exclude, String tableList, String tablePattern, String directory, boolean withBcp, boolean deleteFailedFiles)
          Exports tables within a foreign schema to CSV/BCP files
static void exportMergedSchemas(String origCatalog, String origSchema, String incrCatalog, String incrSchema, boolean exclude, String tableList, String tablePattern, String idColumn, String directory)
          Standard version of local merge schema export which always creates bcp files and deletes any leftover files from failed table exports
static void exportMergedSchemas(String origCatalog, String origSchema, String incrCatalog, String incrSchema, boolean exclude, String tableList, String tablePattern, String idColumn, String directory, boolean withBcp, boolean deleteFailedFiles)
          Used to combine original data and incremental data.
static void exportQueryToFile(String querySql, String pathWithoutExtension, boolean withBcp, boolean deleteFailedFiles)
          Deprecated. Use widest version instead.
static void exportQueryToFile(String querySql, String pathWithoutExtension, boolean withBcp, boolean withData, boolean deleteFailedFiles, String fieldDelimiter, String fileExtension, String dateFormat, String timeFormat, String timestampFormat)
          Exports results of a single query to CSV/BCP files.
static void exportQueryToFile(String querySql, String pathWithoutExtension, boolean withBcp, boolean deleteFailedFiles, String fieldDelimiter, String fileExtension, String dateFormat, String timeFormat, String timestampFormat)
          Deprecated. Use widest version instead.
static void exportSchemaIncrementalToCsv(String catalog, String schema, boolean exclude, String tableList, String tablePattern, Timestamp lastModified, String lastModifiedColumn, String directory)
          Standard version of incremental local schema export which always creates bcp files and deletes any leftover files from failed table exports
static void exportSchemaIncrementalToCsv(String catalog, String schema, boolean exclude, String tableList, String tablePattern, Timestamp lastModified, String lastModifiedColumn, String directory, boolean withBcp, boolean deleteFailedFiles)
          Exports tables within a schema to CSV/BCP files for rows modified after a specified timestamp
static void exportSchemaToCsv(String catalog, String schema, boolean exclude, String tableList, String tablePattern, String directory)
          Standard version of local schema export which always creates bcp files and deletes any leftover files from failed table exports
static void exportSchemaToCsv(String catalog, String schema, boolean exclude, String tableList, String tablePattern, String directory, boolean withBcp, boolean deleteFailedFiles)
          Exports tables within a schema to flat files with BCP files Older version of the export local schema UDP without file extension, field delimiter and datetime format parameters.
static void exportSchemaToFile(String catalog, String schema, boolean exclude, String tableList, String tablePattern, String directory, boolean withBcp, boolean deleteFailedFiles, String fieldDelimiter, String fileExtension)
          Exports tables within a schema to flat files with BCP files
static void exportSchemaToFile(String catalog, String schema, boolean exclude, String tableList, String tablePattern, String directory, boolean withBcp, boolean deleteFailedFiles, String fieldDelimiter, String fileExtension, String dateFormat, String timeFormat, String timestampFormat)
          Exports tables within a schema to flat files with BCP files
static String getBcpLine(int colNum, ResultSetMetaData rsmd, String fieldDelim)
          Helper function which returns a line in BCP file format for a specified column in a table.
private static HashSet<String> getLocalTableNames(String catalog, String schema, boolean exclude, String tableList, String tablePattern, Connection conn)
          Helper function which gets the set of local table names to be exported
private static String getTimestampString()
          Helper function which returns the current timestamp as a string
private static String quote(String value)
          Helper function which escapes the quotes by quoting them
private static void toCsv(int expType, String catalog, String schema, Timestamp lastModified, String columnName, String incrCatalog, String incrSchema, String directory, boolean withBcp, boolean withData, boolean deleteFailedFiles, String fieldDelimiter, String fileExtension, String dateFormat, String timeFormat, String timestampFormat, HashSet<String> tableNames, String querySql, Connection conn)
          Helper function which creates and writes data to CSV and BCP files
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tracer

private static Logger tracer

QUOTE

private static final String QUOTE
See Also:
Constant Field Values

TAB

private static final String TAB
See Also:
Constant Field Values

NEWLINE

private static final String NEWLINE
See Also:
Constant Field Values

TABLE_TYPES

private static final String[] TABLE_TYPES

LOGFILE_PREFIX

private static final String LOGFILE_PREFIX
See Also:
Constant Field Values

FULL_EXPORT

private static final int FULL_EXPORT
See Also:
Constant Field Values

INCR_EXPORT

private static final int INCR_EXPORT
See Also:
Constant Field Values

MERGE_EXPORT

private static final int MERGE_EXPORT
See Also:
Constant Field Values

EXPORT_TYPES

private static final String[] EXPORT_TYPES
Constructor Detail

FarragoExportSchemaUDR

public FarragoExportSchemaUDR()
Method Detail

exportSchemaToFile

public static void exportSchemaToFile(String catalog,
                                      String schema,
                                      boolean exclude,
                                      String tableList,
                                      String tablePattern,
                                      String directory,
                                      boolean withBcp,
                                      boolean deleteFailedFiles,
                                      String fieldDelimiter,
                                      String fileExtension,
                                      String dateFormat,
                                      String timeFormat,
                                      String timestampFormat)
                               throws SQLException
Exports tables within a schema to flat files with BCP files

Parameters:
catalog - name of the catalog where schema resides, if null, default catalog
schema - name of local schema
exclude - if true, tables matching either the table_list of the table_pattern will be excluded. if false, tables will be included
tableList - comma separated list of tables or null value if table_pattern is being used
tablePattern - table name pattern where '_' represents any single character
directory - the directory in which to place the exported CSV and BCP files
withBcp - indicates whether BCP files should be created. If true, BCP files will be created. If false, they will not be created
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
fieldDelimiter - used to delimit column fields in the flat file if null, defaults to tab separated
fileExtension - the file extension for the created flat file, if null, defaults to .txt
dateFormat - format for DATE fields (SimpleDateFormat)
timeFormat - format for TIME fields (SimpleDateFormat)
timestampFormat - format for TIMESTAMP fields (SimpleDateFormat)
Throws:
SQLException

exportSchemaToFile

public static void exportSchemaToFile(String catalog,
                                      String schema,
                                      boolean exclude,
                                      String tableList,
                                      String tablePattern,
                                      String directory,
                                      boolean withBcp,
                                      boolean deleteFailedFiles,
                                      String fieldDelimiter,
                                      String fileExtension)
                               throws SQLException
Exports tables within a schema to flat files with BCP files

Parameters:
catalog - name of the catalog where schema resides, if null, default catalog
schema - name of local schema
exclude - if true, tables matching either the table_list of the table_pattern will be excluded. if false, tables will be included
tableList - comma separated list of tables or null value if table_pattern is being used
tablePattern - table name pattern where '_' represents any single character
directory - the directory in which to place the exported CSV and BCP files
withBcp - indicates whether BCP files should be created. If true, BCP files will be created. If false, they will not be created
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
fieldDelimiter - used to delimit column fields in the flat file if null, defaults to tab separated
fileExtension - the file extension for the created flat file, if null, defaults to .txt
Throws:
SQLException

exportSchemaToCsv

public static void exportSchemaToCsv(String catalog,
                                     String schema,
                                     boolean exclude,
                                     String tableList,
                                     String tablePattern,
                                     String directory,
                                     boolean withBcp,
                                     boolean deleteFailedFiles)
                              throws SQLException
Exports tables within a schema to flat files with BCP files Older version of the export local schema UDP without file extension, field delimiter and datetime format parameters. To be eventually either retired, or changed to output csv files instead of tab separated

Parameters:
catalog - name of the catalog where schema resides, if null, default catalog
schema - name of local schema
exclude - if true, tables matching either the table_list of the table_pattern will be excluded. if false, tables will be included
tableList - comma separated list of tables or null value if table_pattern is being used
tablePattern - table name pattern where '_' represents any single character
directory - the directory in which to place the exported CSV and BCP files
withBcp - indicates whether BCP files should be created. If true, BCP files will be created. If false, they will not be created
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
Throws:
SQLException

exportSchemaToCsv

public static void exportSchemaToCsv(String catalog,
                                     String schema,
                                     boolean exclude,
                                     String tableList,
                                     String tablePattern,
                                     String directory)
                              throws SQLException
Standard version of local schema export which always creates bcp files and deletes any leftover files from failed table exports

Throws:
SQLException

exportForeignSchemaToCsv

public static void exportForeignSchemaToCsv(String foreignServer,
                                            String foreignSchema,
                                            boolean exclude,
                                            String tableList,
                                            String tablePattern,
                                            String directory,
                                            boolean withBcp,
                                            boolean deleteFailedFiles)
                                     throws SQLException
Exports tables within a foreign schema to CSV/BCP files

Parameters:
foreignServer - name of the foreign server
foreignSchema - name of the foreign schema
exclude - if true, tables matching either the tableList of the tablePattern will be excluded. if false, tables will be included
tableList - comma separated list of tables or null value if tablePattern is being used
tablePattern - table name pattern where '_' represents any single character and '%' represents any sequence of zero or more characters. Set to null value if tableList is being used
directory - the directory in which to place the exported CSV and BCP files
withBcp - indicates whether bcp files should be created. if true, bcp files will be created. If false, they will not be created
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
Throws:
SQLException

exportForeignSchemaToCsv

public static void exportForeignSchemaToCsv(String foreignServer,
                                            String foreignSchema,
                                            boolean exclude,
                                            String tableList,
                                            String tablePattern,
                                            String directory)
                                     throws SQLException
Standard version of foreign schema export which always creates bcp files and deletes any leftover files from failed table exports

Throws:
SQLException

exportSchemaIncrementalToCsv

public static void exportSchemaIncrementalToCsv(String catalog,
                                                String schema,
                                                boolean exclude,
                                                String tableList,
                                                String tablePattern,
                                                Timestamp lastModified,
                                                String lastModifiedColumn,
                                                String directory,
                                                boolean withBcp,
                                                boolean deleteFailedFiles)
                                         throws SQLException
Exports tables within a schema to CSV/BCP files for rows modified after a specified timestamp

Parameters:
catalog - name of the catalog where schema resides, if null, default catalog
schema - name of local schema
exclude - if true, tables matching either the tableList of the tablePattern will be excluded. if false, tables will be included
tableList - comma separated list of tables or null value if tablePattern is being used
tablePattern - table name pattern where '_' represents any single character
lastModified - if specified, only rows which were modified after this timestamp will be written to the csv file; lastModifiedColumn must be valid for this field to be used
lastModifiedColumn - name of the column for last modified timestamp, if not specified then all rows will be written
directory - the directory in which to place the exported CSV and BCP files
withBcp - indicates whether BCP files should be created. If true, BCP files will be created. If false, they will not be created
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
Throws:
SQLException

exportSchemaIncrementalToCsv

public static void exportSchemaIncrementalToCsv(String catalog,
                                                String schema,
                                                boolean exclude,
                                                String tableList,
                                                String tablePattern,
                                                Timestamp lastModified,
                                                String lastModifiedColumn,
                                                String directory)
                                         throws SQLException
Standard version of incremental local schema export which always creates bcp files and deletes any leftover files from failed table exports

Throws:
SQLException

exportForeignSchemaIncrementalToCsv

public static void exportForeignSchemaIncrementalToCsv(String foreignServer,
                                                       String foreignSchema,
                                                       boolean exclude,
                                                       String tableList,
                                                       String tablePattern,
                                                       Timestamp lastModified,
                                                       String lastModifiedColumn,
                                                       String directory,
                                                       boolean withBcp,
                                                       boolean deleteFailedFiles)
                                                throws SQLException
Exports tables within a foreign schema to CSV/BCP files for rows modified after a specified timestamp

Parameters:
foreignServer - name of the foreign server
foreignSchema - name of the foreign schema
exclude - if true, tables matching either the tableList of the tablePattern will be excluded. if false, tables will be included
tableList - comma separated list of tables or null value if tablePattern is being used
tablePattern - table name pattern where '_' represents any single character and '%' represents any sequence of zero or more characters. Set to null value if tableList is being used
lastModified - only rows which were modified after this timestamp will be returned
lastModifiedColumn - name of the column for last modified timestamp; if not valid for a table, all rows will be returned
directory - the directory in which to place the exported CSV and BCP files
withBcp - indicates whether bcp files should be created. if true, bcp files will be created. If false, they will not be created
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
Throws:
SQLException

exportForeignSchemaIncrementalToCsv

public static void exportForeignSchemaIncrementalToCsv(String foreignServer,
                                                       String foreignSchema,
                                                       boolean exclude,
                                                       String tableList,
                                                       String tablePattern,
                                                       Timestamp lastModified,
                                                       String lastModifiedColumn,
                                                       String directory)
                                                throws SQLException
Standard version of incremental foreign schema export which always creates bcp files and deletes any leftover files from failed table exports

Throws:
SQLException

exportMergedSchemas

public static void exportMergedSchemas(String origCatalog,
                                       String origSchema,
                                       String incrCatalog,
                                       String incrSchema,
                                       boolean exclude,
                                       String tableList,
                                       String tablePattern,
                                       String idColumn,
                                       String directory,
                                       boolean withBcp,
                                       boolean deleteFailedFiles)
                                throws SQLException
Used to combine original data and incremental data. The data from the original schema which has been deleted will not be updated. Only updates and new records from the incremental schema will be. The tables in the schemas must have the same structure.

Parameters:
origCatalog - name of catalog where original data tables reside
origSchema - name of schema where original data tables reside
incrCatalog - name of catalog where incremental data tables reside
incrSchema - name of schema where incremental data tables reside
idColumn - name of the id column used to join tables
directory - the directory in which to place the exported CSV and BCP files
withBcp - indicates whether bcp files should be created. if true, bcp files will be created. If false, they will not be created
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
Throws:
SQLException

exportMergedSchemas

public static void exportMergedSchemas(String origCatalog,
                                       String origSchema,
                                       String incrCatalog,
                                       String incrSchema,
                                       boolean exclude,
                                       String tableList,
                                       String tablePattern,
                                       String idColumn,
                                       String directory)
                                throws SQLException
Standard version of local merge schema export which always creates bcp files and deletes any leftover files from failed table exports

Throws:
SQLException

getLocalTableNames

private static HashSet<String> getLocalTableNames(String catalog,
                                                  String schema,
                                                  boolean exclude,
                                                  String tableList,
                                                  String tablePattern,
                                                  Connection conn)
                                           throws SQLException
Helper function which gets the set of local table names to be exported

Parameters:
catalog - name of catalog
schema - name of local schema
exclude - if true, tables matching either the tableList of the tablePattern will be excluded. if false, tables will be included
tableList - comma separated list of tables or null value if tablePattern is being used
tablePattern - table name pattern where '_' represents any single character
conn - connection to the database
Returns:
HashSet of types String with the names of all the tables to be exported
Throws:
SQLException

exportForeignSchemaHelper

private static void exportForeignSchemaHelper(int expType,
                                              String foreignServer,
                                              String foreignSchema,
                                              boolean exclude,
                                              String tableList,
                                              String tablePattern,
                                              Timestamp lastModified,
                                              String lastModifiedColumn,
                                              String directory,
                                              boolean withBcp,
                                              boolean deleteFailedFiles)
                                       throws SQLException
Helper function for full and incremental exports of tables within a foreign schema

Parameters:
expType - type of export
foreignServer - name of the foreign server
foreignSchema - name of the foreign schema
exclude - if true, tables matching either the tableList of the tablePattern will be excluded. if false, tables will be included
tableList - comma separated list of tables or null value if tablePattern is being used
tablePattern - table name pattern where '_' represents any single character and '%' represents any sequence of zero or more characters. Set to null value if tableList is being used
lastModified - if specified, only rows which were modified after this timestamp will be returned; lastModifiedColumn must be valid for this field to be used
lastModifiedColumn - name of the column for last modified timestamp, if not specified all rows will be returned
directory - the directory in which to place the exported CSV and BCP files
withBcp - indicates whether bcp files should be created. if true, bcp files will be created. If false, they will not be created
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
Throws:
SQLException

toCsv

private static void toCsv(int expType,
                          String catalog,
                          String schema,
                          Timestamp lastModified,
                          String columnName,
                          String incrCatalog,
                          String incrSchema,
                          String directory,
                          boolean withBcp,
                          boolean withData,
                          boolean deleteFailedFiles,
                          String fieldDelimiter,
                          String fileExtension,
                          String dateFormat,
                          String timeFormat,
                          String timestampFormat,
                          HashSet<String> tableNames,
                          String querySql,
                          Connection conn)
                   throws SQLException
Helper function which creates and writes data to CSV and BCP files

Parameters:
expType - type of export
catalog - name of catalog
schema - name of local schema
lastModified - only used for incremental export, rows which were modified after this timestamp will be written to the csv file lastModifiedColumn must be valid for this field to be used
columnName - for incremental export, name of the last modified timestamp column, for merge export, name of the id column
incrCatalog - only valid for merge export; name of catalog for incremental data
incrSchema - only valid for merge export; name of schema for incremental data
directory - location to write CSV and BCP files
withBcp - if true creates BCP files, if false, doesn't
withData - if true creates data files, if false, doesn't
deleteFailedFiles - if true, csv and bcp files for tables which fail during export will be deleted, otherwise they will remain
dateFormat - format for DATE fields (SimpleDateFormat)
timeFormat - format for TIME fields (SimpleDateFormat)
timestampFormat - format for TIMESTAMP fields (SimpleDateFormat)
tableNames - HashSet with names of the table to export
querySql - SQL query to execute (if non-null, all table-related parameters should be null; and vice versa)
conn - connection to the dtaabase
Throws:
SQLException

exportQueryToFile

public static void exportQueryToFile(String querySql,
                                     String pathWithoutExtension,
                                     boolean withBcp,
                                     boolean deleteFailedFiles)
                              throws SQLException
Deprecated. Use widest version instead.

Exports results of a single query to CSV/BCP files. (Actually currently tab-separated .txt rather than CSV; see FRG-197).

Parameters:
querySql - query whose result is to be executed
pathWithoutExtension - location to write CSV and BCP files; this should be a directory-qualified filename without an extension (correct extension will be appended automatically)
withBcp - if true creates BCP files, if false, doesn't
deleteFailedFiles - if true, csv and bcp files will be deleted if export fails, otherwise they may remain rowcount
Throws:
SQLException

exportQueryToFile

public static void exportQueryToFile(String querySql,
                                     String pathWithoutExtension,
                                     boolean withBcp,
                                     boolean deleteFailedFiles,
                                     String fieldDelimiter,
                                     String fileExtension,
                                     String dateFormat,
                                     String timeFormat,
                                     String timestampFormat)
                              throws SQLException
Deprecated. Use widest version instead.

Exports results of a single query to CSV/BCP files.

Parameters:
querySql - query whose result is to be executed
pathWithoutExtension - location to write CSV and BCP files; this should be a directory-qualified filename without an extension (correct extension will be appended automatically)
withBcp - if true creates BCP files, if false, doesn't
deleteFailedFiles - if true, csv and bcp files will be deleted if export fails, otherwise they may remain rowcount
fieldDelimiter - used to delimit column fields in the flat file if null, defaults to tab separated
fileExtension - the file extension for the created flat file, if null, defaults to .txt
dateFormat - format for DATE fields (SimpleDateFormat)
timeFormat - format for TIME fields (SimpleDateFormat)
timestampFormat - format for TIMESTAMP fields (SimpleDateFormat)
Throws:
SQLException

exportQueryToFile

public static void exportQueryToFile(String querySql,
                                     String pathWithoutExtension,
                                     boolean withBcp,
                                     boolean withData,
                                     boolean deleteFailedFiles,
                                     String fieldDelimiter,
                                     String fileExtension,
                                     String dateFormat,
                                     String timeFormat,
                                     String timestampFormat)
                              throws SQLException
Exports results of a single query to CSV/BCP files.

Parameters:
querySql - query whose result is to be executed
pathWithoutExtension - location to write CSV and BCP files; this should be a directory-qualified filename without an extension (correct extension will be appended automatically)
withBcp - if true creates BCP file, if false, doesn't
withData - if true creates data file, if false, doesn't
deleteFailedFiles - if true, csv and bcp files will be deleted if export fails, otherwise they may remain rowcount
fieldDelimiter - used to delimit column fields in the flat file if null, defaults to tab separated
fileExtension - the file extension for the created flat file, if null, defaults to .txt
dateFormat - format for DATE fields (SimpleDateFormat)
timeFormat - format for TIME fields (SimpleDateFormat)
timestampFormat - format for TIMESTAMP fields (SimpleDateFormat)
Throws:
SQLException

getBcpLine

public static String getBcpLine(int colNum,
                                ResultSetMetaData rsmd,
                                String fieldDelim)
                         throws SQLException
Helper function which returns a line in BCP file format for a specified column in a table. Note: this uses BCP types that aren't standard such as SQLDATE and SQLTIME, SQLTIMESTAMP, SQLVARBINARY, and the extra columns specifying precision and scale for SQLDECIMAL

Parameters:
colNum - column number to return BCP control data for
rsmd - metadata for the table
Throws:
SQLException

quote

private static String quote(String value)
Helper function which escapes the quotes by quoting them

Parameters:
value - string in which to replace quotes with quoted quotes
Returns:
string with all quotes escaped

getTimestampString

private static String getTimestampString()
Helper function which returns the current timestamp as a string

Returns:
current date and time as a string

buildQuerySql

private static String buildQuerySql(int expType,
                                    String catalog,
                                    String schema,
                                    String tblName,
                                    Timestamp lastModifiedTs,
                                    String colName,
                                    String incrCatalog,
                                    String incrSchema)
Helper function to build sql to query tables


buildImportForeignSchemaSql

private static String buildImportForeignSchemaSql(String foreignServer,
                                                  String foreignSchema,
                                                  String tableList,
                                                  String tablePattern,
                                                  boolean exclude,
                                                  String tempSchema)
Helper function to build the import foreign schema SQL used in exporting from a foreign schema


checkColumnName

private static int checkColumnName(int expType,
                                   String catalog,
                                   String schema,
                                   String incrCatalog,
                                   String incrSchema,
                                   String tableName,
                                   String columnName,
                                   Connection conn)
                            throws SQLException
Checks the column names passed in are valid for a table; last modified column for incremental export and id column for merge export

Returns:
export type to attempt, same as the export type passed in if column exists, full export otherwise
Throws:
SQLException