Class SQLServerBulkBatchInsertRecord

java.lang.Object
com.microsoft.sqlserver.jdbc.SQLServerBulkBatchInsertRecord
All Implemented Interfaces:
ISQLServerBulkData, ISQLServerBulkRecord, java.io.Serializable

public class SQLServerBulkBatchInsertRecord
extends java.lang.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 java.util.Map<java.lang.Integer,​com.microsoft.sqlserver.jdbc.SQLServerBulkRecord.ColumnMetadata> columnMetadata  
    protected java.lang.String[] columnNames  
    protected java.time.format.DateTimeFormatter dateTimeFormatter  
    protected static java.util.logging.Logger loggerExternal  
    protected java.lang.String loggerPackageName  
    protected java.time.format.DateTimeFormatter timeFormatter  
  • Constructor Summary

    Constructors 
    Constructor Description
    SQLServerBulkBatchInsertRecord​(java.util.ArrayList<com.microsoft.sqlserver.jdbc.Parameter[]> batchParam, java.util.ArrayList<java.lang.String> columnList, java.util.ArrayList<java.lang.String> valueList, java.lang.String encoding)  
  • Method Summary

    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)  
    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)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • columnNames

      protected java.lang.String[] columnNames
    • columnMetadata

      protected java.util.Map<java.lang.Integer,​com.microsoft.sqlserver.jdbc.SQLServerBulkRecord.ColumnMetadata> columnMetadata
    • dateTimeFormatter

      protected java.time.format.DateTimeFormatter dateTimeFormatter
    • timeFormatter

      protected java.time.format.DateTimeFormatter timeFormatter
    • loggerPackageName

      protected java.lang.String loggerPackageName
    • loggerExternal

      protected static java.util.logging.Logger loggerExternal
  • Constructor Details

    • SQLServerBulkBatchInsertRecord

      public SQLServerBulkBatchInsertRecord​(java.util.ArrayList<com.microsoft.sqlserver.jdbc.Parameter[]> batchParam, java.util.ArrayList<java.lang.String> columnList, java.util.ArrayList<java.lang.String> valueList, java.lang.String encoding) throws SQLServerException
      Throws:
      SQLServerException
  • Method Details

    • getRowData

      public java.lang.Object[] getRowData() throws SQLServerException
      Description copied from interface: ISQLServerBulkData
      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

      public boolean next() throws SQLServerException
      Description copied from interface: ISQLServerBulkData
      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

      public void addColumnMetadata​(int positionInSource, java.lang.String name, int jdbcType, int precision, int scale, java.time.format.DateTimeFormatter dateTimeFormatter) throws SQLServerException
      Description copied from interface: ISQLServerBulkRecord
      Adds metadata for the given column in the file.
      Specified by:
      addColumnMetadata in interface ISQLServerBulkRecord
      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 column
      precision - 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, java.lang.String name, int jdbcType, int precision, int scale) throws SQLServerException
      Description copied from interface: ISQLServerBulkRecord
      Adds metadata for the given column in the file.
      Specified by:
      addColumnMetadata in interface ISQLServerBulkRecord
      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 column
      precision - 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

      public void setTimestampWithTimezoneFormat​(java.lang.String dateTimeFormat)
      Description copied from interface: ISQLServerBulkRecord
      Sets the format for reading in dates from the file.
      Specified by:
      setTimestampWithTimezoneFormat in interface ISQLServerBulkRecord
      Parameters:
      dateTimeFormat - format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
    • setTimestampWithTimezoneFormat

      public void setTimestampWithTimezoneFormat​(java.time.format.DateTimeFormatter dateTimeFormatter)
      Description copied from interface: ISQLServerBulkRecord
      Sets the format for reading in dates from the file.
      Specified by:
      setTimestampWithTimezoneFormat in interface ISQLServerBulkRecord
      Parameters:
      dateTimeFormatter - format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
    • setTimeWithTimezoneFormat

      public void setTimeWithTimezoneFormat​(java.lang.String timeFormat)
      Description copied from interface: ISQLServerBulkRecord
      Sets the format for reading in dates from the file.
      Specified by:
      setTimeWithTimezoneFormat in interface ISQLServerBulkRecord
      Parameters:
      timeFormat - format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
    • setTimeWithTimezoneFormat

      public void setTimeWithTimezoneFormat​(java.time.format.DateTimeFormatter dateTimeFormatter)
      Description copied from interface: ISQLServerBulkRecord
      Sets the format for reading in dates from the file.
      Specified by:
      setTimeWithTimezoneFormat in interface ISQLServerBulkRecord
      Parameters:
      dateTimeFormatter - format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
    • throwInvalidArgument

      protected void throwInvalidArgument​(java.lang.String argument) throws SQLServerException
      Throws:
      SQLServerException
    • checkDuplicateColumnName

      protected void checkDuplicateColumnName​(int positionInTable, java.lang.String colName) throws SQLServerException
      Throws:
      SQLServerException
    • getColumnDateTimeFormatter

      public java.time.format.DateTimeFormatter getColumnDateTimeFormatter​(int column)
      Description copied from interface: ISQLServerBulkRecord
      Returns the dateTimeFormatter for the given column.
      Specified by:
      getColumnDateTimeFormatter in interface ISQLServerBulkRecord
      Parameters:
      column - Column ordinal
      Returns:
      dateTimeFormatter
    • getColumnOrdinals

      public java.util.Set<java.lang.Integer> getColumnOrdinals()
      Description copied from interface: ISQLServerBulkData
      Returns the ordinals for each of the columns represented in this data record.
      Specified by:
      getColumnOrdinals in interface ISQLServerBulkData
      Returns:
      Set of ordinals for the columns.
    • getColumnName

      public java.lang.String getColumnName​(int column)
      Description copied from interface: ISQLServerBulkData
      Returns the name of the given column.
      Specified by:
      getColumnName in interface ISQLServerBulkData
      Parameters:
      column - Column ordinal
      Returns:
      Name of the column
    • getColumnType

      public int getColumnType​(int column)
      Description copied from interface: ISQLServerBulkData
      Returns the JDBC data type of the given column.
      Specified by:
      getColumnType in interface ISQLServerBulkData
      Parameters:
      column - Column ordinal
      Returns:
      JDBC data type of the column
    • getPrecision

      public int getPrecision​(int column)
      Description copied from interface: ISQLServerBulkData
      Returns the precision for the given column.
      Specified by:
      getPrecision in interface ISQLServerBulkData
      Parameters:
      column - Column ordinal
      Returns:
      Precision of the column
    • getScale

      public int getScale​(int column)
      Description copied from interface: ISQLServerBulkData
      Returns the scale for the given column.
      Specified by:
      getScale in interface ISQLServerBulkData
      Parameters:
      column - Column ordinal
      Returns:
      Scale of the column
    • isAutoIncrement

      public boolean isAutoIncrement​(int column)
      Description copied from interface: ISQLServerBulkRecord
      Returns whether the column represents an identity column.
      Specified by:
      isAutoIncrement in interface ISQLServerBulkRecord
      Parameters:
      column - Column ordinal
      Returns:
      True if the column is an identity column; false otherwise.