Package com.microsoft.sqlserver.jdbc
Class SQLServerBulkBatchInsertRecord
- java.lang.Object
-
- com.microsoft.sqlserver.jdbc.SQLServerBulkBatchInsertRecord
-
- All Implemented Interfaces:
ISQLServerBulkRecord,Serializable
public class SQLServerBulkBatchInsertRecord extends Object
Provides a simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java data types from an ArrayList of Parameters that were provided by pstmt/cstmt.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Integer,com.microsoft.sqlserver.jdbc.SQLServerBulkCommon.ColumnMetadata>columnMetadataprotected String[]columnNamesprotected DateTimeFormatterdateTimeFormatterprotected DateTimeFormattertimeFormatter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColumnMetadata(int positionInSource, String name, int jdbcType, int precision, int scale)Adds metadata for the given column in the file.voidaddColumnMetadata(int positionInSource, String name, int jdbcType, int precision, int scale, DateTimeFormatter dateTimeFormatter)Adds metadata for the given column in the file.protected voidcheckDuplicateColumnName(int positionInTable, String colName)DateTimeFormattergetColumnDateTimeFormatter(int column)Returns thedateTimeFormatterfor the given column.StringgetColumnName(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.intgetColumnType(int column)Returns the JDBC data type of the given column.intgetPrecision(int column)Returns the precision for the given column.Object[]getRowData()Returns the data for the current row as an array of Objects.intgetScale(int column)Returns the scale for the given column.booleanisAutoIncrement(int column)Returns whether the column represents an identity column.booleannext()Advances to the next data row.voidsetTimestampWithTimezoneFormat(String dateTimeFormat)Sets the format for reading in dates from the file.voidsetTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter)Sets the format for reading in dates from the file.voidsetTimeWithTimezoneFormat(String timeFormat)Sets the format for reading in dates from the file.voidsetTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter)Sets the format for reading in dates from the file.protected voidthrowInvalidArgument(String argument)
-
-
-
Field Detail
-
columnNames
protected String[] columnNames
-
columnMetadata
protected Map<Integer,com.microsoft.sqlserver.jdbc.SQLServerBulkCommon.ColumnMetadata> columnMetadata
-
dateTimeFormatter
protected DateTimeFormatter dateTimeFormatter
-
timeFormatter
protected DateTimeFormatter timeFormatter
-
-
Constructor Detail
-
SQLServerBulkBatchInsertRecord
public SQLServerBulkBatchInsertRecord(ArrayList<com.microsoft.sqlserver.jdbc.Parameter[]> batchParam, ArrayList<String> columnList, ArrayList<String> valueList, String encoding) throws SQLServerException
- Throws:
SQLServerException
-
-
Method Detail
-
getColumnDateTimeFormatter
public DateTimeFormatter getColumnDateTimeFormatter(int column)
Description copied from interface:ISQLServerBulkRecordReturns thedateTimeFormatterfor the given column.- Parameters:
column- Column ordinal- Returns:
- dateTimeFormatter
-
getColumnOrdinals
public Set<Integer> getColumnOrdinals()
Description copied from interface:ISQLServerBulkRecordReturns the ordinals for each of the columns represented in this data record.- Returns:
- Set of ordinals for the columns.
-
getColumnName
public String getColumnName(int column)
Description copied from interface:ISQLServerBulkRecordReturns the name of the given column.- Parameters:
column- Column ordinal- Returns:
- Name of the column
-
getColumnType
public int getColumnType(int column)
Description copied from interface:ISQLServerBulkRecordReturns the JDBC data type of the given column.- Parameters:
column- Column ordinal- Returns:
- JDBC data type of the column
-
getPrecision
public int getPrecision(int column)
Description copied from interface:ISQLServerBulkRecordReturns the precision for the given column.- Parameters:
column- Column ordinal- Returns:
- Precision of the column
-
getScale
public int getScale(int column)
Description copied from interface:ISQLServerBulkRecordReturns the scale for the given column.- Parameters:
column- Column ordinal- Returns:
- Scale of the column
-
isAutoIncrement
public boolean isAutoIncrement(int column)
Description copied from interface:ISQLServerBulkRecordReturns whether the column represents an identity column.- Parameters:
column- Column ordinal- Returns:
- True if the column is an identity column; false otherwise.
-
getRowData
public Object[] getRowData() throws SQLServerException
Description copied from interface:ISQLServerBulkRecordReturns 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.
-
setTimestampWithTimezoneFormat
public void setTimestampWithTimezoneFormat(String dateTimeFormat)
Description copied from interface:ISQLServerBulkRecordSets the format for reading in dates from the file.- Specified by:
setTimestampWithTimezoneFormatin interfaceISQLServerBulkRecord- Parameters:
dateTimeFormat- format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
-
setTimestampWithTimezoneFormat
public void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter)
Description copied from interface:ISQLServerBulkRecordSets the format for reading in dates from the file.- Specified by:
setTimestampWithTimezoneFormatin interfaceISQLServerBulkRecord- Parameters:
dateTimeFormatter- format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
-
setTimeWithTimezoneFormat
public void setTimeWithTimezoneFormat(String timeFormat)
Description copied from interface:ISQLServerBulkRecordSets the format for reading in dates from the file.- Specified by:
setTimeWithTimezoneFormatin interfaceISQLServerBulkRecord- Parameters:
timeFormat- format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
-
setTimeWithTimezoneFormat
public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter)
Description copied from interface:ISQLServerBulkRecordSets the format for reading in dates from the file.- Specified by:
setTimeWithTimezoneFormatin interfaceISQLServerBulkRecord- Parameters:
dateTimeFormatter- format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
-
next
public boolean next() throws SQLServerExceptionDescription copied from interface:ISQLServerBulkRecordAdvances 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
public void addColumnMetadata(int positionInSource, String name, int jdbcType, int precision, int scale, DateTimeFormatter dateTimeFormatter) throws SQLServerExceptionDescription copied from interface:ISQLServerBulkRecordAdds metadata for the given column in the file.- Specified by:
addColumnMetadatain interfaceISQLServerBulkRecord- Parameters:
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 sent- Throws:
SQLServerException- when an error occurs
-
addColumnMetadata
public void addColumnMetadata(int positionInSource, String name, int jdbcType, int precision, int scale) throws SQLServerExceptionDescription copied from interface:ISQLServerBulkRecordAdds metadata for the given column in the file.- Specified by:
addColumnMetadatain interfaceISQLServerBulkRecord- Parameters:
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)- Throws:
SQLServerException- when an error occurs
-
throwInvalidArgument
protected void throwInvalidArgument(String argument) throws SQLServerException
- Throws:
SQLServerException
-
checkDuplicateColumnName
protected void checkDuplicateColumnName(int positionInTable, String colName) throws SQLServerException- Throws:
SQLServerException
-
-