org.apache.derby.impl.load
Class Import

java.lang.Object
  extended by org.apache.derby.vti.VTITemplate
      extended by org.apache.derby.impl.load.ImportAbstract
          extended by org.apache.derby.impl.load.Import
All Implemented Interfaces:
java.sql.ResultSet, java.sql.Wrapper

public class Import
extends ImportAbstract

This class implements import of data from a URL into a table. Import functions provided here in this class shouble be called through Systement Procedures. Import uses VTI , which is supprted only through Systemem procedures mechanism.


Field Summary
private static int _importCounter
           
private static java.util.Hashtable _importers
           
private  java.lang.String inputFileName
           
 
Fields inherited from class org.apache.derby.impl.load.ImportAbstract
COLUMNNAMEPREFIX, columnNames, columnTypeNames, columnTypeNamesString, columnWidths, controlFileReader, importReadData, importResultSetMetaData, lineNumber, lobsInExtFile, nextRow, noOfColumnsExpected, numberOfColumns, tableColumnTypes, tableColumnTypesStr, udtClasses, udtClassNamesString
 
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
 
Constructor Summary
Import(java.lang.String inputFileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, int noOfColumnsExpected, java.lang.String columnTypes, boolean lobsInExtFile, int importCounter, java.lang.String columnTypeNames, java.lang.String udtClassNamesString)
          Constructior to Invoke Import from a select statement
 
Method Summary
private static int bumpImportCounter()
           
private  void doImport()
           
private static java.sql.SQLException formatImportError(Import importer, java.lang.String inputFile, java.lang.Throwable t)
           
(package private)  ImportReadData getImportReadData()
          virtual method from the abstract class
static void importData(java.sql.Connection connection, java.lang.String schemaName, java.lang.String tableName, java.lang.String insertColumnList, java.lang.String columnIndexes, java.lang.String inputFileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace, boolean lobsInExtFile)
          SYSCS_IMPORT_DATA system Procedure from ij or from a Java application invokes this method to perform import to a table from a file.
static void importTable(java.sql.Connection connection, java.lang.String schemaName, java.lang.String tableName, java.lang.String inputFileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace, boolean lobsInExtFile)
          SYSCS_IMPORT_TABLE system Procedure from ij or from a Java application invokes this method to perform import to a table from a file.
private static void performImport(java.sql.Connection connection, java.lang.String schemaName, java.lang.String insertColumnList, java.lang.String columnIndexes, java.lang.String tableName, java.lang.String inputFileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace, boolean lobsInExtFile)
           
private static java.lang.String quoteStringArgument(java.lang.String string)
          Quote a string argument so that it can be used as a literal in an SQL statement.
 
Methods inherited from class org.apache.derby.impl.load.ImportAbstract
close, destringifyObject, doAllTheWork, getBlob, getBytes, getClob, getCurrentLineNumber, getMetaData, getObject, getRow, getString, importError, loadColumnNames, next, readObject, wasNull
 
Methods inherited from class org.apache.derby.vti.VTITemplate
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getCharacterStream, getCharacterStream, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getInt, getInt, getLong, getLong, getObject, getObject, getObject, getRef, getRef, getShort, getShort, getStatement, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateShort, updateShort, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.ResultSet
getHoldability, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getRowId, getRowId, getSQLXML, getSQLXML, isClosed, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateRowId, updateRowId, updateSQLXML, updateSQLXML
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Field Detail

_importCounter

private static int _importCounter

_importers

private static java.util.Hashtable _importers

inputFileName

private java.lang.String inputFileName
Constructor Detail

Import

public Import(java.lang.String inputFileName,
              java.lang.String columnDelimiter,
              java.lang.String characterDelimiter,
              java.lang.String codeset,
              int noOfColumnsExpected,
              java.lang.String columnTypes,
              boolean lobsInExtFile,
              int importCounter,
              java.lang.String columnTypeNames,
              java.lang.String udtClassNamesString)
       throws java.sql.SQLException
Constructior to Invoke Import from a select statement

Parameters:
inputFileName - The URL of the ASCII file from which import will happen
Throws:
java.lang.Exception - on error
java.sql.SQLException
Method Detail

doImport

private void doImport()
               throws java.lang.Exception
Throws:
java.lang.Exception

importTable

public static void importTable(java.sql.Connection connection,
                               java.lang.String schemaName,
                               java.lang.String tableName,
                               java.lang.String inputFileName,
                               java.lang.String columnDelimiter,
                               java.lang.String characterDelimiter,
                               java.lang.String codeset,
                               short replace,
                               boolean lobsInExtFile)
                        throws java.sql.SQLException
SYSCS_IMPORT_TABLE system Procedure from ij or from a Java application invokes this method to perform import to a table from a file.

Parameters:
connection - The Derby database connection URL for the database containing the table
schemaName - The name of the schema where table to import exists
tableName - Name of the Table the data has to be imported to.
inputFileName - Name of the file from which data has to be imported.
columnDelimiter - Delimiter that seperates columns in the file
characterDelimiter - Delimiter that is used to quiote non-numeric types
codeset - Codeset of the data in the file
replace - Indicates whether the data in table has to be replaced or appended.(0 - append , > 0 Replace the data)
lobsInExtFile - true, if the lobs data is stored in an external file, and the reference to it is stored in the main import file.
Throws:
SQL - Exception on errors
java.sql.SQLException

importData

public static void importData(java.sql.Connection connection,
                              java.lang.String schemaName,
                              java.lang.String tableName,
                              java.lang.String insertColumnList,
                              java.lang.String columnIndexes,
                              java.lang.String inputFileName,
                              java.lang.String columnDelimiter,
                              java.lang.String characterDelimiter,
                              java.lang.String codeset,
                              short replace,
                              boolean lobsInExtFile)
                       throws java.sql.SQLException
SYSCS_IMPORT_DATA system Procedure from ij or from a Java application invokes this method to perform import to a table from a file.

Parameters:
connection - The Derby database connection URL for the database containing the table
schemaName - The name of the schema where table to import exists
tableName - Name of the Table the data has to be imported to.
insertColumnList - Comma Seperated column name list to which data has to be imported from file.eg: 'c2,c2,'c3'.
columnIndexes - Comma sepearted Lit Index of the columns in the file(first column starts at 1). eg: '3 ,4 , 5'
inputFileName - Name of the file from which data has to be imported.
columnDelimiter - Delimiter that seperates columns in the file
characterDelimiter - Delimiter that is used to quiote non-numeric types
codeset - Codeset of the data in the file
replace - Indicates whether the data in table has to be replaced or appended.(0 - append , > 0 Replace the data)
lobsInExtFile - true, if the lobs data is stored in an external file, and the reference is stored in the main import file.
Throws:
SQL - Exception on errors
java.sql.SQLException

performImport

private static void performImport(java.sql.Connection connection,
                                  java.lang.String schemaName,
                                  java.lang.String insertColumnList,
                                  java.lang.String columnIndexes,
                                  java.lang.String tableName,
                                  java.lang.String inputFileName,
                                  java.lang.String columnDelimiter,
                                  java.lang.String characterDelimiter,
                                  java.lang.String codeset,
                                  short replace,
                                  boolean lobsInExtFile)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

getImportReadData

ImportReadData getImportReadData()
                           throws java.lang.Exception
virtual method from the abstract class

Specified by:
getImportReadData in class ImportAbstract
Throws:
java.lang.Exception - on error

bumpImportCounter

private static int bumpImportCounter()

formatImportError

private static java.sql.SQLException formatImportError(Import importer,
                                                       java.lang.String inputFile,
                                                       java.lang.Throwable t)

quoteStringArgument

private static java.lang.String quoteStringArgument(java.lang.String string)
Quote a string argument so that it can be used as a literal in an SQL statement. If the string argument is null an SQL NULL token is returned.

Parameters:
string - a string or null
Returns:
the string in quotes and with proper escape sequences for special characters, or "NULL" if the string is null

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.