org.apache.derby.impl.load
Class Import
- java.lang.Object
-
- org.apache.derby.vti.VTITemplate
-
- org.apache.derby.impl.load.Import
-
- All Implemented Interfaces:
- java.lang.AutoCloseable, java.sql.ResultSet, java.sql.Wrapper, AwareVTI
public class Import extends VTITemplate
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.derby.vti.VTITemplate
VTITemplate.ColumnDescriptor
-
-
Constructor Summary
Constructors Constructor and Description 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)Constructor to Invoke Import from a select statement
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()closes the resultsetstatic java.lang.ObjectdestringifyObject(java.lang.String raw)Read an object which was serialized to a string using StringUtiljava.sql.BlobgetBlob(int columnIndex)Returnsjava.sql.Blobtype object that contains the column data from the import file.byte[]getBytes(int columnIndex)Returns byte array that contains the column data from the import file.java.sql.ClobgetClob(int columnIndex)Returnsjava.sql.Clobtype object that contains the column data from the import file.intgetCurrentLineNumber()gets the current line numberjava.sql.ResultSetMetaDatagetMetaData()Gets the resultset meta datajava.lang.ObjectgetObject(int columnIndex)Returns Object that contains the column data from the import file.intgetRow()gets the next rowjava.lang.StringgetString(int columnIndex)static voidimportData(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.java.sql.SQLExceptionimportError(java.lang.Exception ex)Close the stream and wrap exception in a SQLExceptionstatic voidimportTable(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.booleannext()static java.lang.ObjectreadObject(byte[] bytes)Read a serializable from a set of bytes.booleanwasNull()-
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, getContext, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getInt, getLong, getLong, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getReturnTableSignature, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getStatement, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isWrapperFor, last, moveToCurrentRow, moveToInsertRow, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setContext, setFetchDirection, setFetchSize, unwrap, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp
-
-
-
-
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.SQLExceptionConstructor to Invoke Import from a select statement- Parameters:
inputFileName- The URL of the ASCII file from which import will happen- Throws:
java.sql.SQLException- on error
-
-
Method Detail
-
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.SQLExceptionSYSCS_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 tableschemaName- The name of the schema where table to import existstableName- 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 filecharacterDelimiter- Delimiter that is used to quiote non-numeric typescodeset- Codeset of the data in the filereplace- 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:
java.sql.SQLException- on errors
-
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.SQLExceptionSYSCS_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 tableschemaName- The name of the schema where table to import existstableName- 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 filecharacterDelimiter- Delimiter that is used to quiote non-numeric typescodeset- Codeset of the data in the filereplace- 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:
java.sql.SQLException- on errors
-
getMetaData
public java.sql.ResultSetMetaData getMetaData()
Gets the resultset meta data- Specified by:
getMetaDatain interfacejava.sql.ResultSet- Overrides:
getMetaDatain classVTITemplate- Throws:
java.sql.SQLException- if there is an error
-
getRow
public int getRow() throws java.sql.SQLExceptiongets the next row- Specified by:
getRowin interfacejava.sql.ResultSet- Overrides:
getRowin classVTITemplate- Throws:
java.sql.SQLException- if there is an error
-
getCurrentLineNumber
public int getCurrentLineNumber()
gets the current line number
-
next
public boolean next() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
close
public void close() throws java.sql.SQLExceptioncloses the resultset- Throws:
java.sql.SQLException- if there is an error
-
wasNull
public boolean wasNull()
- Specified by:
wasNullin interfacejava.sql.ResultSet- Overrides:
wasNullin classVTITemplate
-
getString
public java.lang.String getString(int columnIndex) throws java.sql.SQLException- Specified by:
getStringin interfacejava.sql.ResultSet- Overrides:
getStringin classVTITemplate- Throws:
java.sql.SQLException- if there is an error
-
getClob
public java.sql.Clob getClob(int columnIndex) throws java.sql.SQLExceptionReturnsjava.sql.Clobtype object that contains the column data from the import file.- Specified by:
getClobin interfacejava.sql.ResultSet- Overrides:
getClobin classVTITemplate- Parameters:
columnIndex- number of the column. starts at 1.- Throws:
java.sql.SQLException- if any occurs during create of the clob object.
-
getBlob
public java.sql.Blob getBlob(int columnIndex) throws java.sql.SQLExceptionReturnsjava.sql.Blobtype object that contains the column data from the import file.- Specified by:
getBlobin interfacejava.sql.ResultSet- Overrides:
getBlobin classVTITemplate- Parameters:
columnIndex- number of the column. starts at 1.- Throws:
java.sql.SQLException- if any occurs during create of the blob object.
-
getObject
public java.lang.Object getObject(int columnIndex) throws java.sql.SQLExceptionReturns Object that contains the column data from the import file.- Specified by:
getObjectin interfacejava.sql.ResultSet- Overrides:
getObjectin classVTITemplate- Parameters:
columnIndex- number of the column. starts at 1.- Throws:
java.sql.SQLException- if any error occurs.
-
readObject
public static java.lang.Object readObject(byte[] bytes) throws java.lang.ExceptionRead a serializable from a set of bytes.- Throws:
java.lang.Exception
-
destringifyObject
public static java.lang.Object destringifyObject(java.lang.String raw) throws java.lang.ExceptionRead an object which was serialized to a string using StringUtil- Throws:
java.lang.Exception
-
getBytes
public byte[] getBytes(int columnIndex) throws java.sql.SQLExceptionReturns byte array that contains the column data from the import file.- Specified by:
getBytesin interfacejava.sql.ResultSet- Overrides:
getBytesin classVTITemplate- Parameters:
columnIndex- number of the column. starts at 1.- Throws:
java.sql.SQLException- if any error occurs.
-
importError
public java.sql.SQLException importError(java.lang.Exception ex)
Close the stream and wrap exception in a SQLException- Parameters:
ex- Exception causing the import error- Throws:
java.sql.SQLException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG