ISQLServerBulkRecord
, java.lang.AutoCloseable
public class SQLServerBulkCSVFileRecord
extends java.lang.Object
implements java.lang.AutoCloseable
Modifier and Type | Field | Description |
---|---|---|
protected java.util.Map<java.lang.Integer,com.microsoft.sqlserver.jdbc.SQLServerBulkCommon.ColumnMetadata> |
columnMetadata |
|
protected java.lang.String[] |
columnNames |
|
protected java.time.format.DateTimeFormatter |
dateTimeFormatter |
|
protected java.time.format.DateTimeFormatter |
timeFormatter |
Constructor | Description |
---|---|
SQLServerBulkCSVFileRecord(java.io.InputStream fileToParse,
java.lang.String encoding,
java.lang.String delimiter,
boolean firstLineIsColumnNames) |
Constructs a SQLServerBulkCSVFileRecord to parse data from a delimited file with the given encoding.
|
SQLServerBulkCSVFileRecord(java.lang.String fileToParse,
boolean firstLineIsColumnNames) |
Constructs a SQLServerBulkCSVFileRecord to parse data from a CSV file with the default encoding.
|
SQLServerBulkCSVFileRecord(java.lang.String fileToParse,
java.lang.String encoding,
boolean firstLineIsColumnNames) |
Constructs a SQLServerBulkCSVFileRecord to parse data from a CSV file with the given encoding.
|
SQLServerBulkCSVFileRecord(java.lang.String fileToParse,
java.lang.String encoding,
java.lang.String delimiter,
boolean firstLineIsColumnNames) |
Constructs a simple reader to parse data from a delimited file with the given encoding.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addColumnMetadata(int positionInSource,
java.lang.String name,
int jdbcType,
int precision,
int scale) |
Adds metadata for the given column in the file.
|
void |
addColumnMetadata(int positionInSource,
java.lang.String name,
int jdbcType,
int precision,
int scale,
java.time.format.DateTimeFormatter dateTimeFormatter) |
Adds metadata for the given column in the file.
|
protected void |
checkDuplicateColumnName(int positionInTable,
java.lang.String colName) |
|
void |
close() |
Releases any resources associated with the file reader.
|
java.time.format.DateTimeFormatter |
getColumnDateTimeFormatter(int column) |
Returns the
dateTimeFormatter for the given column. |
java.lang.String |
getColumnName(int column) |
Returns the name of the given column.
|
java.util.Set<java.lang.Integer> |
getColumnOrdinals() |
Returns the ordinals for each of the columns represented in this data record.
|
int |
getColumnType(int column) |
Returns the JDBC data type of the given column.
|
int |
getPrecision(int column) |
Returns the precision for the given column.
|
java.lang.Object[] |
getRowData() |
Returns the data for the current row as an array of Objects.
|
int |
getScale(int column) |
Returns the scale for the given column.
|
boolean |
isAutoIncrement(int column) |
Returns whether the column represents an identity column.
|
boolean |
next() |
Advances to the next data row.
|
void |
setTimestampWithTimezoneFormat(java.lang.String dateTimeFormat) |
Sets the format for reading in dates from the file.
|
void |
setTimestampWithTimezoneFormat(java.time.format.DateTimeFormatter dateTimeFormatter) |
Sets the format for reading in dates from the file.
|
void |
setTimeWithTimezoneFormat(java.lang.String timeFormat) |
Sets the format for reading in dates from the file.
|
void |
setTimeWithTimezoneFormat(java.time.format.DateTimeFormatter dateTimeFormatter) |
Sets the format for reading in dates from the file.
|
protected void |
throwInvalidArgument(java.lang.String argument) |
protected java.lang.String[] columnNames
protected java.util.Map<java.lang.Integer,com.microsoft.sqlserver.jdbc.SQLServerBulkCommon.ColumnMetadata> columnMetadata
protected java.time.format.DateTimeFormatter dateTimeFormatter
protected java.time.format.DateTimeFormatter timeFormatter
public SQLServerBulkCSVFileRecord(java.lang.String fileToParse, java.lang.String encoding, java.lang.String delimiter, boolean firstLineIsColumnNames) throws SQLServerException
fileToParse
- File to parse data fromencoding
- Charset encoding to use for reading the file, or NULL for the default encoding.delimiter
- Delimiter to used to separate each columnfirstLineIsColumnNames
- True if the first line of the file should be parsed as column names; false otherwiseSQLServerException
- If the arguments are invalid, there are any errors in reading the file, or the file is emptypublic SQLServerBulkCSVFileRecord(java.io.InputStream fileToParse, java.lang.String encoding, java.lang.String delimiter, boolean firstLineIsColumnNames) throws SQLServerException
fileToParse
- InputStream to parse data fromencoding
- Charset encoding to use for reading the file, or NULL for the default encoding.delimiter
- Delimiter to used to separate each columnfirstLineIsColumnNames
- True if the first line of the file should be parsed as column names; false otherwiseSQLServerException
- If the arguments are invalid, there are any errors in reading the file, or the file is emptypublic SQLServerBulkCSVFileRecord(java.lang.String fileToParse, java.lang.String encoding, boolean firstLineIsColumnNames) throws SQLServerException
fileToParse
- File to parse data fromencoding
- Charset encoding to use for reading the file.firstLineIsColumnNames
- True if the first line of the file should be parsed as column names; false otherwiseSQLServerException
- If the arguments are invalid, there are any errors in reading the file, or the file is emptypublic SQLServerBulkCSVFileRecord(java.lang.String fileToParse, boolean firstLineIsColumnNames) throws SQLServerException
fileToParse
- File to parse data fromfirstLineIsColumnNames
- True if the first line of the file should be parsed as column names; false otherwiseSQLServerException
- If the arguments are invalid, there are any errors in reading the file, or the file is emptypublic void close() throws SQLServerException
close
in interface java.lang.AutoCloseable
SQLServerException
- when an error occurspublic java.time.format.DateTimeFormatter getColumnDateTimeFormatter(int column)
ISQLServerBulkRecord
dateTimeFormatter
for the given column.getColumnDateTimeFormatter
in interface ISQLServerBulkRecord
column
- Column ordinalpublic java.util.Set<java.lang.Integer> getColumnOrdinals()
ISQLServerBulkRecord
getColumnOrdinals
in interface ISQLServerBulkRecord
public java.lang.String getColumnName(int column)
ISQLServerBulkRecord
getColumnName
in interface ISQLServerBulkRecord
column
- Column ordinalpublic int getColumnType(int column)
ISQLServerBulkRecord
getColumnType
in interface ISQLServerBulkRecord
column
- Column ordinalpublic int getPrecision(int column)
ISQLServerBulkRecord
getPrecision
in interface ISQLServerBulkRecord
column
- Column ordinalpublic int getScale(int column)
ISQLServerBulkRecord
getScale
in interface ISQLServerBulkRecord
column
- Column ordinalpublic boolean isAutoIncrement(int column)
ISQLServerBulkRecord
isAutoIncrement
in interface ISQLServerBulkRecord
column
- Column ordinalpublic java.lang.Object[] getRowData() throws SQLServerException
ISQLServerBulkRecord
getRowData
in interface ISQLServerBulkRecord
SQLServerException
- If there are any errors in obtaining the data.public void setTimestampWithTimezoneFormat(java.lang.String dateTimeFormat)
ISQLServerBulkRecord
setTimestampWithTimezoneFormat
in interface ISQLServerBulkRecord
dateTimeFormat
- format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONEpublic void setTimestampWithTimezoneFormat(java.time.format.DateTimeFormatter dateTimeFormatter)
ISQLServerBulkRecord
setTimestampWithTimezoneFormat
in interface ISQLServerBulkRecord
dateTimeFormatter
- format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONEpublic void setTimeWithTimezoneFormat(java.lang.String timeFormat)
ISQLServerBulkRecord
setTimeWithTimezoneFormat
in interface ISQLServerBulkRecord
timeFormat
- format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONEpublic void setTimeWithTimezoneFormat(java.time.format.DateTimeFormatter dateTimeFormatter)
ISQLServerBulkRecord
setTimeWithTimezoneFormat
in interface ISQLServerBulkRecord
dateTimeFormatter
- format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONEpublic boolean next() throws SQLServerException
ISQLServerBulkRecord
next
in interface ISQLServerBulkRecord
SQLServerException
- If there are any errors in advancing to the next row.public void addColumnMetadata(int positionInSource, java.lang.String name, int jdbcType, int precision, int scale, java.time.format.DateTimeFormatter dateTimeFormatter) throws SQLServerException
ISQLServerBulkRecord
addColumnMetadata
in interface ISQLServerBulkRecord
positionInSource
- Indicates which column the metadata is for. Columns start at 1.name
- Name for the column (optional if only using column ordinal in a mapping for SQLServerBulkCopy operation)jdbcType
- JDBC data type of the columnprecision
- Precision for the column (ignored for the appropriate data types)scale
- Scale for the column (ignored for the appropriate data types)dateTimeFormatter
- format to parse data that is sentSQLServerException
- when an error occurspublic void addColumnMetadata(int positionInSource, java.lang.String name, int jdbcType, int precision, int scale) throws SQLServerException
ISQLServerBulkRecord
addColumnMetadata
in interface ISQLServerBulkRecord
positionInSource
- Indicates which column the metadata is for. Columns start at 1.name
- Name for the column (optional if only using column ordinal in a mapping for SQLServerBulkCopy operation)jdbcType
- JDBC data type of the columnprecision
- Precision for the column (ignored for the appropriate data types)scale
- Scale for the column (ignored for the appropriate data types)SQLServerException
- when an error occursprotected void throwInvalidArgument(java.lang.String argument) throws SQLServerException
SQLServerException
protected void checkDuplicateColumnName(int positionInTable, java.lang.String colName) throws SQLServerException
SQLServerException
Copyright © 2018 Microsoft Corporation. All rights reserved.