Package com.microsoft.sqlserver.jdbc
Interface ISQLServerBulkRecord
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
SQLServerBulkBatchInsertRecord
,SQLServerBulkCSVFileRecord
public interface ISQLServerBulkRecord extends Serializable
Provides an interface used to create classes that read in data from any source (such as a file) and allows a SQLServerBulkCopy class to write the data to SQL Server tables. This interface is implemented bySQLServerBulkCommon
Class
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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, DateTimeFormatter dateTimeFormatter)
Adds metadata for the given column in the file.DateTimeFormatter
getColumnDateTimeFormatter(int column)
Returns thedateTimeFormatter
for the given column.String
getColumnName(int column)
Returns the name of the given column.Set<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.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(String dateTimeFormat)
Sets the format for reading in dates from the file.void
setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter)
Sets the format for reading in dates from the file.void
setTimeWithTimezoneFormat(String timeFormat)
Sets the format for reading in dates from the file.void
setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter)
Sets the format for reading in dates from the file.
-
-
-
Method Detail
-
getColumnOrdinals
Set<Integer> getColumnOrdinals()
Returns the ordinals for each of the columns represented in this data record.- Returns:
- Set of ordinals for the columns.
-
getColumnName
String getColumnName(int column)
Returns the name of the given column.- Parameters:
column
- Column ordinal- Returns:
- Name of the column
-
getColumnType
int getColumnType(int column)
Returns the JDBC data type of the given column.- Parameters:
column
- Column ordinal- Returns:
- JDBC data type of the column
-
getPrecision
int getPrecision(int column)
Returns the precision for the given column.- Parameters:
column
- Column ordinal- Returns:
- Precision of the column
-
getScale
int getScale(int column)
Returns the scale for the given column.- Parameters:
column
- Column ordinal- Returns:
- Scale of the column
-
isAutoIncrement
boolean isAutoIncrement(int column)
Returns whether the column represents an identity column.- Parameters:
column
- Column ordinal- Returns:
- True if the column is an identity column; false otherwise.
-
getRowData
Object[] getRowData() throws SQLServerException
Returns the data for the current row as an array of Objects. Each Object must match the Java language Type that is used to represent the indicated JDBC data type for the given column. For more information, see 'Understanding the JDBC Driver Data Types' for the appropriate mappings.- Returns:
- The data for the row.
- Throws:
SQLServerException
- If there are any errors in obtaining the data.
-
next
boolean next() throws SQLServerException
Advances to the next data row.- Returns:
- True if rows are available; false if there are no more rows
- Throws:
SQLServerException
- If there are any errors in advancing to the next row.
-
addColumnMetadata
void addColumnMetadata(int positionInFile, String name, int jdbcType, int precision, int scale, DateTimeFormatter dateTimeFormatter) throws SQLServerException
Adds metadata for the given column in the file.- Parameters:
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 sent- Throws:
SQLServerException
- when an error occurs
-
addColumnMetadata
void addColumnMetadata(int positionInFile, String name, int jdbcType, int precision, int scale) throws SQLServerException
Adds metadata for the given column in the file.- Parameters:
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)- Throws:
SQLServerException
- when an error occurs
-
setTimestampWithTimezoneFormat
void setTimestampWithTimezoneFormat(String dateTimeFormat)
Sets the format for reading in dates from the file.- Parameters:
dateTimeFormat
- format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
-
setTimestampWithTimezoneFormat
void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter)
Sets the format for reading in dates from the file.- Parameters:
dateTimeFormatter
- format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
-
setTimeWithTimezoneFormat
void setTimeWithTimezoneFormat(String timeFormat)
Sets the format for reading in dates from the file.- Parameters:
timeFormat
- format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
-
setTimeWithTimezoneFormat
void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter)
Sets the format for reading in dates from the file.- Parameters:
dateTimeFormatter
- format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
-
getColumnDateTimeFormatter
DateTimeFormatter getColumnDateTimeFormatter(int column)
Returns thedateTimeFormatter
for the given column.- Parameters:
column
- Column ordinal- Returns:
- dateTimeFormatter
-
-