public class SQLServerBulkCopy extends Object implements AutoCloseable
Constructor and Description |
---|
SQLServerBulkCopy(Connection connection)
Initializes a new instance of the SQLServerBulkCopy class using the specified open instance of SQLServerConnection.
|
SQLServerBulkCopy(String connectionUrl)
Initializes and opens a new instance of SQLServerConnection based on the supplied connectionString.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumnMapping(int sourceColumn,
int destinationColumn)
Adds a new column mapping, using ordinals to specify both the source and destination columns.
|
void |
addColumnMapping(int sourceColumn,
String destinationColumn)
Adds a new column mapping, using an ordinal for the source column and a string for the destination column.
|
void |
addColumnMapping(String sourceColumn,
int destinationColumn)
Adds a new column mapping, using a column name to describe the source column and an ordinal to specify the destination column.
|
void |
addColumnMapping(String sourceColumn,
String destinationColumn)
Adds a new column mapping, using column names to specify both source and destination columns.
|
void |
clearColumnMappings()
Clears the contents of the column mappings
|
void |
close()
Closes the SQLServerBulkCopy instance
|
SQLServerBulkCopyOptions |
getBulkCopyOptions()
Gets the current SQLServerBulkCopyOptions.
|
String |
getDestinationTableName()
Gets the name of the destination table on the server.
|
protected Object |
getTemporalObjectFromCSVWithFormatter(String valueStrUntrimmed,
int srcJdbcType,
int srcColOrdinal,
java.time.format.DateTimeFormatter dateTimeFormatter) |
void |
setBulkCopyOptions(SQLServerBulkCopyOptions copyOptions)
Update the behavior of the SQLServerBulkCopy instance according to the options supplied.
|
void |
setDestinationTableName(String tableName)
Sets the name of the destination table on the server.
|
void |
writeToServer(ISQLServerBulkRecord sourceData)
Copies all rows from the supplied ISQLServerBulkRecord to a destination table specified by the destinationTableName property of the SQLServerBulkCopy object.
|
void |
writeToServer(ResultSet sourceData)
Copies all rows in the supplied ResultSet to a destination table specified by the destinationTableName property of the SQLServerBulkCopy object.
|
void |
writeToServer(RowSet sourceData)
Copies all rows in the supplied RowSet to a destination table specified by the destinationTableName property of the SQLServerBulkCopy object.
|
public SQLServerBulkCopy(Connection connection) throws SQLServerException
connection
- Open instance of Connection to destination server. Must be from the Microsoft JDBC driver for SQL Server.SQLServerException
- If the supplied type is not a connection from the Microsoft JDBC driver for SQL Server.public SQLServerBulkCopy(String connectionUrl) throws SQLException
connectionUrl
- Connection string for the destination server.SQLException
- If a connection cannot be established.public void addColumnMapping(int sourceColumn, int destinationColumn) throws SQLServerException
sourceColumn
- Source column ordinal.destinationColumn
- Destination column ordinal.SQLServerException
- If the column mapping is invalidpublic void addColumnMapping(int sourceColumn, String destinationColumn) throws SQLServerException
sourceColumn
- Source column ordinal.destinationColumn
- Destination column name.SQLServerException
- If the column mapping is invalidpublic void addColumnMapping(String sourceColumn, int destinationColumn) throws SQLServerException
sourceColumn
- Source column name.destinationColumn
- Destination column ordinal.SQLServerException
- If the column mapping is invalidpublic void addColumnMapping(String sourceColumn, String destinationColumn) throws SQLServerException
sourceColumn
- Source column name.destinationColumn
- Destination column name.SQLServerException
- If the column mapping is invalidpublic void clearColumnMappings()
public void close()
close
in interface AutoCloseable
public String getDestinationTableName()
public void setDestinationTableName(String tableName) throws SQLServerException
tableName
- Destination table name.SQLServerException
- If the table name is nullpublic SQLServerBulkCopyOptions getBulkCopyOptions()
public void setBulkCopyOptions(SQLServerBulkCopyOptions copyOptions) throws SQLServerException
copyOptions
- Settings to change how the WriteToServer methods behave.SQLServerException
- If the SQLServerBulkCopyOption class was constructed using an existing Connection and
the UseInternalTransaction option is specified.public void writeToServer(ResultSet sourceData) throws SQLServerException
sourceData
- ResultSet to read data rows from.SQLServerException
- If there are any issues encountered when performing the bulk copy operationpublic void writeToServer(RowSet sourceData) throws SQLServerException
sourceData
- RowSet to read data rows from.SQLServerException
- If there are any issues encountered when performing the bulk copy operationpublic void writeToServer(ISQLServerBulkRecord sourceData) throws SQLServerException
sourceData
- SQLServerBulkReader to read data rows from.SQLServerException
- If there are any issues encountered when performing the bulk copy operationprotected Object getTemporalObjectFromCSVWithFormatter(String valueStrUntrimmed, int srcJdbcType, int srcColOrdinal, java.time.format.DateTimeFormatter dateTimeFormatter) throws SQLServerException
SQLServerException
Copyright © 2016. All rights reserved.