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

Add | Add support in SQLServerBulkCopy to allow Pooled/XA Connection instances during object creation. #968

Merged
merged 10 commits into from
Mar 11, 2019
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ services:
env:
global:
- mssql_jdbc_logging='true'
# Enabling logging with console / file handler for JUnit Test Framework.
#- mssql_jdbc_logging_handler='console'|'file'

# Enabling logging with console / file handler for JUnit Test Framework.
# - mssql_jdbc_logging_handler='console'|'file'

#Cache the .m2 folder
cache:
Expand All @@ -33,7 +34,7 @@ install:

before_script:
- docker pull mcr.microsoft.com/mssql/server:latest
- export SQLPWD=$(</dev/urandom tr -dc 'A-Za-z0-9#!' | head -c 15;)
- export SQLPWD=$(</dev/urandom tr -dc 'A-Za-z0-9!' | head -c 15;)
- export mssql_jdbc_test_connection_properties="jdbc:sqlserver://localhost:1433;databaseName=master;username=sa;password=$SQLPWD"
- docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$SQLPWD" -p 1433:1433 -d mcr.microsoft.com/mssql/server:latest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.logging.Level;

import javax.sql.RowSet;
import javax.sql.XAConnection;

import microsoft.sql.DateTimeOffset;

Expand Down Expand Up @@ -270,13 +271,15 @@ class BulkColumnMetaData {
public SQLServerBulkCopy(Connection connection) throws SQLServerException {
loggerExternal.entering(loggerClassName, "SQLServerBulkCopy", connection);

if (null == connection || !(connection instanceof SQLServerConnection)) {
if (null == connection || !(connection instanceof ISQLServerConnection)) {
SQLServerException.makeFromDriverError(null, null,
SQLServerException.getErrString("R_invalidDestConnection"), null, false);
}

if (connection instanceof SQLServerConnection) {
this.connection = (SQLServerConnection) connection;
} else if (connection instanceof SQLServerConnectionPoolProxy) {
this.connection = ((SQLServerConnectionPoolProxy) connection).getWrappedConnection();
cheenamalhotra marked this conversation as resolved.
Show resolved Hide resolved
} else {
SQLServerException.makeFromDriverError(null, null,
SQLServerException.getErrString("R_invalidDestConnection"), null, false);
Expand Down Expand Up @@ -1962,9 +1965,9 @@ private void writeColumnToTdsWriter(TDSWriter tdsWriter, int bulkPrecision, int
bulkJdbcType = java.sql.Types.VARBINARY;
}
/*
* if source is encrypted and destination is unencrypted, use destination sql type to send since there is no
* way of finding if source is encrypted without accessing the resultset, send destination type if source
* resultset set is of type SQLServer and encryption is enabled
* if source is encrypted and destination is unencrypted, use destination sql type to send since there is no way
* of finding if source is encrypted without accessing the resultset, send destination type if source resultset
* set is of type SQLServer and encryption is enabled
*/
else if (null != sourceCryptoMeta) {
bulkJdbcType = destColumnMetadata.get(destColOrdinal).jdbcType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public String toString() {
bIsOpen = true;
}

SQLServerConnection getWrappedConnection() {
return wrappedConnection;
}

void checkClosed() throws SQLServerException {
if (!bIsOpen) {
SQLServerException.makeFromDriverError(null, null, SQLServerException.getErrString("R_connectionIsClosed"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ private void testBulkCopyResultSet(boolean setSelectMethod, Integer resultSetTyp
bcOperation.writeToServer(rs);
bcOperation.close();

ComparisonUtil.compareSrcTableAndDestTableIgnoreRowOrder(new DBConnection(connection), tableSrc,
tableDest);
ComparisonUtil.compareSrcTableAndDestTableIgnoreRowOrder(new DBConnection(connection), tableSrc, tableDest);
} finally {
terminateVariation();
}
Expand Down
Loading