Top Description Fields Constructors Methods
org.apache.derby.impl.load

public Class Import

extends ImportAbstract
Class Inheritance
Imports
java.sql.SQLException, .Statement, .PreparedStatement, .Connection, java.util.*, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.error.StandardException, .PublicAPI, org.apache.derby.iapi.security.Securable, .SecurityUtil, org.apache.derby.iapi.util.IdUtil, .StringUtil

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

Modifier and TypeField and Description
private static int
private static Hashtable<Integer, Import>
private String
private static short
Inherited from org.apache.derby.impl.load.ImportAbstract:
COLUMNNAMEPREFIXcolumnNamescolumnTypeNamescolumnTypeNamesStringcolumnWidthscontrolFileReaderimportReadDataimportResultSetMetaDatalineNumberlobsInExtFilenextRownoOfColumnsExpectednumberOfColumnstableColumnTypestableColumnTypesStrudtClassesudtClassNamesString

Constructor Summary

AccessConstructor and Description
public
Import(String
The URL of the ASCII file from which import will happen
inputFileName
,
String columnDelimiter, String characterDelimiter, String codeset, int noOfColumnsExpected, String columnTypes, boolean lobsInExtFile, int importCounter, String columnTypeNames, String udtClassNamesString)

Constructor to Invoke Import from a select statement

Method Summary

Modifier and TypeMethod and Description
private static synchronized int
private void
private static SQLException
formatImportError(Import importer, String inputFile, Throwable t)

pack-priv ImportReadData
getImportReadData()

Implements abstract org.apache.derby.impl.load.ImportAbstract.getImportReadData.

virtual method from the abstract class

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

SYSCS_IMPORT_DATA system Procedure from ij or from a Java application invokes this method to perform import to a table from a file.

public static void
importTable(Connection
The Derby database connection URL for the database containing the table
connection
,
String
The name of the schema where table to import exists
schemaName
,
String
Name of the Table the data has to be imported to.
tableName
,
String
Name of the file from which data has to be imported.
inputFileName
,
String
Delimiter that seperates columns in the file
columnDelimiter
,
String
Delimiter that is used to quiote non-numeric types
characterDelimiter
,
String
Codeset of the data in the file
codeset
,
short
Indicates whether the data in table has to be replaced or appended.(0 - append , > 0 Replace the data)
replace
,
boolean
true, if the lobs data is stored in an external file, and the reference to it is stored in the main import file.
lobsInExtFile
,
short... extraArgs)

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(Connection connection, String schemaName, String insertColumnList, String columnIndexes, String tableName, String inputFileName, String columnDelimiter, String characterDelimiter, String codeset, short replace, boolean lobsInExtFile)

private static String

Returns:

the string in quotes and with proper escape sequences for special characters, or "NULL" if the string is null
quoteStringArgument
(String
a string or null
string
)

Quote a string argument so that it can be used as a literal in an SQL statement.

private static String[]
readHeaders(String inputFileName, String characterDelimiter, String columnDelimiter, String codeset)

Inherited from org.apache.derby.impl.load.ImportAbstract:
closedestringifyObjectdoAllTheWorkgetBlobgetBytesgetClobgetCurrentLineNumbergetMetaDatagetObjectgetRowgetStringimportErrorloadColumnNamesnextreadObjectwasNull

Field Detail

_importCounterback to summary
private static int _importCounter
_importersback to summary
private static Hashtable<Integer, Import> _importers
inputFileNameback to summary
private String inputFileName
skipback to summary
private static short skip

Constructor Detail

Importback to summary
public Import(String inputFileName, String columnDelimiter, String characterDelimiter, String codeset, int noOfColumnsExpected, String columnTypes, boolean lobsInExtFile, int importCounter, String columnTypeNames, String udtClassNamesString) throws SQLException

Constructor to Invoke Import from a select statement

Parameters
inputFileName:String

The URL of the ASCII file from which import will happen

Exceptions
SQLException:
on error

Method Detail

bumpImportCounterback to summary
private static synchronized int bumpImportCounter()
doImportback to summary
private void doImport() throws Exception
formatImportErrorback to summary
private static SQLException formatImportError(Import importer, String inputFile, Throwable t)
getImportReadDataback to summary
pack-priv ImportReadData getImportReadData() throws Exception

Implements abstract org.apache.derby.impl.load.ImportAbstract.getImportReadData.

virtual method from the abstract class

Exceptions
Exception:
on error
importDataback to summary
public static void importData(Connection connection, String schemaName, String tableName, String insertColumnList, String columnIndexes, String inputFileName, String columnDelimiter, String characterDelimiter, String codeset, short replace, boolean lobsInExtFile, short... extraArgs) throws 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:Connection

The Derby database connection URL for the database containing the table

schemaName:String

The name of the schema where table to import exists

tableName:String

Name of the Table the data has to be imported to.

insertColumnList:String

Comma Seperated column name list to which data has to be imported from file.eg: 'c2,c2,'c3'.

columnIndexes:String

Comma sepearted Lit Index of the columns in the file(first column starts at 1). eg: '3 ,4 , 5'

inputFileName:String

Name of the file from which data has to be imported.

columnDelimiter:String

Delimiter that seperates columns in the file

characterDelimiter:String

Delimiter that is used to quiote non-numeric types

codeset:String

Codeset of the data in the file

replace:short

Indicates whether the data in table has to be replaced or appended.(0 - append , > 0 Replace the data)

lobsInExtFile:boolean

true, if the lobs data is stored in an external file, and the reference is stored in the main import file.

Exceptions
SQLException:
on errors
importTableback to summary
public static void importTable(Connection connection, String schemaName, String tableName, String inputFileName, String columnDelimiter, String characterDelimiter, String codeset, short replace, boolean lobsInExtFile, short... extraArgs) throws 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. The extraArgs parameter is variadic, and is used when this method is called from SYSCS_IMPORT_TABLE_BULK, in which case extraArgs[0] specifies the number of header lines to skip.

Parameters
connection:Connection

The Derby database connection URL for the database containing the table

schemaName:String

The name of the schema where table to import exists

tableName:String

Name of the Table the data has to be imported to.

inputFileName:String

Name of the file from which data has to be imported.

columnDelimiter:String

Delimiter that seperates columns in the file

characterDelimiter:String

Delimiter that is used to quiote non-numeric types

codeset:String

Codeset of the data in the file

replace:short

Indicates whether the data in table has to be replaced or appended.(0 - append , > 0 Replace the data)

lobsInExtFile:boolean

true, if the lobs data is stored in an external file, and the reference to it is stored in the main import file.

Exceptions
SQLException:
on errors
performImportback to summary
private static void performImport(Connection connection, String schemaName, String insertColumnList, String columnIndexes, String tableName, String inputFileName, String columnDelimiter, String characterDelimiter, String codeset, short replace, boolean lobsInExtFile) throws SQLException
quoteStringArgumentback to summary
private static String quoteStringArgument(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:String

a string or null

Returns:String

the string in quotes and with proper escape sequences for special characters, or "NULL" if the string is null

readHeadersback to summary
private static String[] readHeaders(String inputFileName, String characterDelimiter, String columnDelimiter, String codeset) throws SQLException