Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix | Added ISQLServerBulkData to remove implementation details from ISQLServerBulkRecord #1099

Merged
merged 9 commits into from
Oct 4, 2019
79 changes: 79 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made
* available under the terms of the MIT License. See the LICENSE file in the project root for more information.
*/

package com.microsoft.sqlserver.jdbc;

import java.io.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.
*/
public interface ISQLServerBulkData extends Serializable {

/**
* Returns the ordinals for each of the columns represented in this data record.
*
* @return Set of ordinals for the columns.
*/
java.util.Set<Integer> getColumnOrdinals();
jonfreedman marked this conversation as resolved.
Show resolved Hide resolved

/**
* Returns the name of the given column.
*
* @param column
* Column ordinal
* @return Name of the column
*/
String getColumnName(int column);

/**
* Returns the JDBC data type of the given column.
*
* @param column
* Column ordinal
* @return JDBC data type of the column
*/
int getColumnType(int column);

/**
* Returns the precision for the given column.
*
* @param column
* Column ordinal
* @return Precision of the column
*/
int getPrecision(int column);

/**
* Returns the scale for the given column.
*
* @param column
* Column ordinal
* @return Scale of the column
*/
int getScale(int column);

/**
* 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.
*
* @return The data for the row.
* @throws SQLServerException
* If there are any errors in obtaining the data.
*/
Object[] getRowData() throws SQLServerException;

/**
* Advances to the next data row.
*
* @return 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.
*/
boolean next() throws SQLServerException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package com.microsoft.sqlserver.jdbc;

import java.io.Serializable;
import java.time.format.DateTimeFormatter;


Expand All @@ -14,81 +13,20 @@
* SQLServerBulkCopy class to write the data to SQL Server tables.
*
* This interface is implemented by {@link SQLServerBulkRecord} Class
*
* @deprecated as of 7.5.0, because the interface contains methods which are not called as part of actual bulk copy
* process. Use {@link ISQLServerBulkData}} instead.
*/
public interface ISQLServerBulkRecord extends Serializable {

/**
* Returns the ordinals for each of the columns represented in this data record.
*
* @return Set of ordinals for the columns.
*/
public java.util.Set<Integer> getColumnOrdinals();

/**
* Returns the name of the given column.
*
* @param column
* Column ordinal
* @return Name of the column
*/
public String getColumnName(int column);

/**
* Returns the JDBC data type of the given column.
*
* @param column
* Column ordinal
* @return JDBC data type of the column
*/
public int getColumnType(int column);

/**
* Returns the precision for the given column.
*
* @param column
* Column ordinal
* @return Precision of the column
*/
public int getPrecision(int column);

/**
* Returns the scale for the given column.
*
* @param column
* Column ordinal
* @return Scale of the column
*/
public int getScale(int column);

@Deprecated
public interface ISQLServerBulkRecord extends ISQLServerBulkData {
jonfreedman marked this conversation as resolved.
Show resolved Hide resolved
/**
* Returns whether the column represents an identity column.
*
*
* @param column
* Column ordinal
* @return True if the column is an identity column; false otherwise.
*/
public boolean isAutoIncrement(int column);

/**
* 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.
*
* @return The data for the row.
* @throws SQLServerException
* If there are any errors in obtaining the data.
*/
public Object[] getRowData() throws SQLServerException;

/**
* Advances to the next data row.
*
* @return 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.
*/
public boolean next() throws SQLServerException;
boolean isAutoIncrement(int column);

/**
* Adds metadata for the given column in the file.
Expand All @@ -108,7 +46,7 @@ public interface ISQLServerBulkRecord extends Serializable {
* @throws SQLServerException
* when an error occurs
*/
public void addColumnMetadata(int positionInFile, String name, int jdbcType, int precision, int scale,
void addColumnMetadata(int positionInFile, String name, int jdbcType, int precision, int scale,
DateTimeFormatter dateTimeFormatter) throws SQLServerException;

/**
Expand All @@ -127,7 +65,7 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int
* @throws SQLServerException
* when an error occurs
*/
public void addColumnMetadata(int positionInFile, String name, int jdbcType, int precision,
void addColumnMetadata(int positionInFile, String name, int jdbcType, int precision,
int scale) throws SQLServerException;

/**
Expand All @@ -136,31 +74,31 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int
* @param dateTimeFormat
* format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
*/
public void setTimestampWithTimezoneFormat(String dateTimeFormat);
void setTimestampWithTimezoneFormat(String dateTimeFormat);

/**
* Sets the format for reading in dates from the file.
*
* @param dateTimeFormatter
* format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
*/
public void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter);
void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter);

/**
* Sets the format for reading in dates from the file.
*
* @param timeFormat
* format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
*/
public void setTimeWithTimezoneFormat(String timeFormat);
void setTimeWithTimezoneFormat(String timeFormat);

/**
* Sets the format for reading in dates from the file.
*
* @param dateTimeFormatter
* format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
*/
public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter);
void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter);

/**
* Returns the <code>dateTimeFormatter</code> for the given column.
Expand All @@ -169,5 +107,5 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int
* Column ordinal
* @return dateTimeFormatter
*/
public DateTimeFormatter getColumnDateTimeFormatter(int column);
DateTimeFormatter getColumnDateTimeFormatter(int column);
}
Loading