org.apache.derby.impl.load
Class Import

java.lang.Object
  extended byorg.apache.derby.vti.VTITemplate
      extended byorg.apache.derby.impl.load.ImportAbstract
          extended byorg.apache.derby.impl.load.Import
All Implemented Interfaces:
java.sql.ResultSet

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
protected static java.lang.String COLUMNNAMEPREFIX
           
protected  java.lang.String[] columnNames
           
protected  int[] columnWidths
           
protected  ControlInfo controlFileReader
           
protected  ImportReadData importReadData
           
protected  java.sql.ResultSetMetaData importResultSetMetaData
           
private  java.lang.String inputFileName
           
protected  java.lang.String[] nextRow
           
protected  int noOfColumnsExpected
           
protected  int numberOfColumns
           
 
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)
          Constructior to Invoke Import from a select statement
 
Method Summary
 void close()
          closes the resultset
protected  void doAllTheWork()
          Does all the work
private  void doImport()
           
protected  ImportReadData getImportReadData()
          virtual method from the abstract class
 java.sql.ResultSetMetaData getMetaData()
          Gets the resultset meta data
 int getRow()
          gets the next row
 java.lang.String getString(int columnIndex)
           
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)
          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)
          SYSCS_IMPORT_TABLE system Procedure from ij or from a Java application invokes this method to perform import to a table from a file.
protected  void loadColumnNames()
           
 boolean next()
           
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 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, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getInt, getInt, getLong, getLong, getObject, 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
 

Field Detail

inputFileName

private java.lang.String inputFileName

controlFileReader

protected ControlInfo controlFileReader

importReadData

protected ImportReadData importReadData

columnNames

protected java.lang.String[] columnNames

numberOfColumns

protected int numberOfColumns

columnWidths

protected int[] columnWidths

nextRow

protected java.lang.String[] nextRow

importResultSetMetaData

protected java.sql.ResultSetMetaData importResultSetMetaData

noOfColumnsExpected

protected int noOfColumnsExpected

COLUMNNAMEPREFIX

protected static final java.lang.String COLUMNNAMEPREFIX
See Also:
Constant Field Values
Constructor Detail

Import

public Import(java.lang.String inputFileName,
              java.lang.String columnDelimiter,
              java.lang.String characterDelimiter,
              java.lang.String codeset,
              int noOfColumnsExpected)
       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)
                        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:
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.
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)
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)
                       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:
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.
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)
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)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

getImportReadData

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

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

doAllTheWork

protected void doAllTheWork()
                     throws java.lang.Exception
Does all the work

Throws:
java.lang.Exception - if there is an error

loadColumnNames

protected void loadColumnNames()

getMetaData

public java.sql.ResultSetMetaData getMetaData()
Gets the resultset meta data

Throws:
java.sql.SQLException - if there is an error

getRow

public int getRow()
           throws java.sql.SQLException
gets the next row

Specified by:
getRow in interface java.sql.ResultSet
Overrides:
getRow in class VTITemplate
Throws:
java.sql.SQLException - if there is an error
See Also:
ResultSet

next

public boolean next()
             throws java.sql.SQLException
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
closes the resultset

Throws:
java.sql.SQLException - if there is an error

wasNull

public boolean wasNull()
Specified by:
wasNull in interface java.sql.ResultSet
Overrides:
wasNull in class VTITemplate
See Also:
ResultSet

getString

public java.lang.String getString(int columnIndex)
                           throws java.sql.SQLException
Specified by:
getString in interface java.sql.ResultSet
Overrides:
getString in class VTITemplate
Throws:
java.sql.SQLException - if there is an error
See Also:
ResultSet

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.