Skip to content

Commit

Permalink
Add | Add support in SQLServerBulkCopy to allow Pooled/XA Connection …
Browse files Browse the repository at this point in the history
…instances during object creation. (#968)
  • Loading branch information
cheenamalhotra authored Mar 11, 2019
1 parent 5c202b1 commit f56b868
Show file tree
Hide file tree
Showing 16 changed files with 595 additions and 338 deletions.
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();
} 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

0 comments on commit f56b868

Please sign in to comment.