public class SQLServerBulkCSVFileRecord extends Object implements ISQLServerBulkRecord, AutoCloseable
| Constructor and Description |
|---|
SQLServerBulkCSVFileRecord(InputStream fileToParse,
String encoding,
String delimiter,
boolean firstLineIsColumnNames)
Creates a simple reader to parse data from a delimited file with the given encoding.
|
SQLServerBulkCSVFileRecord(String fileToParse,
boolean firstLineIsColumnNames)
Creates a simple reader to parse data from a CSV file with the default encoding.
|
SQLServerBulkCSVFileRecord(String fileToParse,
String encoding,
boolean firstLineIsColumnNames)
Creates a simple reader to parse data from a CSV file with the given encoding.
|
SQLServerBulkCSVFileRecord(String fileToParse,
String encoding,
String delimiter,
boolean firstLineIsColumnNames)
Creates a simple reader to parse data from a delimited file with the given encoding.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addColumnMetadata(int positionInFile,
String name,
int jdbcType,
int precision,
int scale)
Adds metadata for the given column in the file.
|
void |
addColumnMetadata(int positionInFile,
String name,
int jdbcType,
int precision,
int scale,
java.time.format.DateTimeFormatter dateTimeFormatter)
Adds metadata for the given column in the file.
|
void |
close()
Releases any resources associated with the file reader.
|
java.time.format.DateTimeFormatter |
getColumnDateTimeFormatter(int column) |
String |
getColumnName(int column)
Get the name of the given column.
|
Set<Integer> |
getColumnOrdinals()
Get the ordinals for each of the columns represented in this data record.
|
int |
getColumnType(int column)
Get the JDBC data type of the given column.
|
int |
getPrecision(int column)
Get the precision for the given column.
|
Object[] |
getRowData()
Gets the data for the current row as an array of Objects.
|
int |
getScale(int column)
Get the scale for the given column.
|
boolean |
isAutoIncrement(int column)
Indicates whether the column represents an identity column.
|
boolean |
next()
Advances to the next data row.
|
void |
setTimestampWithTimezoneFormat(java.time.format.DateTimeFormatter dateTimeFormatter)
Set the format for reading in dates from the file.
|
void |
setTimestampWithTimezoneFormat(String dateTimeFormat)
Set the format for reading in dates from the file.
|
void |
setTimeWithTimezoneFormat(java.time.format.DateTimeFormatter dateTimeFormatter)
Set the format for reading in dates from the file.
|
void |
setTimeWithTimezoneFormat(String timeFormat)
Set the format for reading in dates from the file.
|
public SQLServerBulkCSVFileRecord(String fileToParse, String encoding, 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(InputStream fileToParse, String encoding, 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(String fileToParse, 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(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 addColumnMetadata(int positionInFile,
String name,
int jdbcType,
int precision,
int scale,
java.time.format.DateTimeFormatter dateTimeFormatter)
throws SQLServerException
positionInFile - 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 positionInFile,
String name,
int jdbcType,
int precision,
int scale)
throws SQLServerException
positionInFile - 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 occurspublic void setTimestampWithTimezoneFormat(String dateTimeFormat)
dateTimeFormat - format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONEpublic void setTimestampWithTimezoneFormat(java.time.format.DateTimeFormatter dateTimeFormatter)
dateTimeFormatter - format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONEpublic void setTimeWithTimezoneFormat(String timeFormat)
timeFormat - format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONEpublic void setTimeWithTimezoneFormat(java.time.format.DateTimeFormatter dateTimeFormatter)
dateTimeFormatter - format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONEpublic void close()
throws SQLServerException
close in interface AutoCloseableSQLServerException - when an error occurspublic java.time.format.DateTimeFormatter getColumnDateTimeFormatter(int column)
public Set<Integer> getColumnOrdinals()
ISQLServerBulkRecordgetColumnOrdinals in interface ISQLServerBulkRecordpublic String getColumnName(int column)
ISQLServerBulkRecordgetColumnName in interface ISQLServerBulkRecordcolumn - Column ordinalpublic int getColumnType(int column)
ISQLServerBulkRecordgetColumnType in interface ISQLServerBulkRecordcolumn - Column ordinalpublic int getPrecision(int column)
ISQLServerBulkRecordgetPrecision in interface ISQLServerBulkRecordcolumn - Column ordinalpublic int getScale(int column)
ISQLServerBulkRecordgetScale in interface ISQLServerBulkRecordcolumn - Column ordinalpublic boolean isAutoIncrement(int column)
ISQLServerBulkRecordisAutoIncrement in interface ISQLServerBulkRecordcolumn - Column ordinalpublic Object[] getRowData() throws SQLServerException
ISQLServerBulkRecordgetRowData in interface ISQLServerBulkRecordSQLServerException - If there are any errors in obtaining the data.public boolean next()
throws SQLServerException
ISQLServerBulkRecordnext in interface ISQLServerBulkRecordSQLServerException - If there are any errors in advancing to the next row.Copyright © 2018 Microsoft Corporation. All rights reserved.