@@ -799,11 +799,15 @@ private void writeColumnMetaDataColumnData(TDSWriter tdsWriter,
799
799
isStreaming = (DataTypes .SHORT_VARTYPE_MAX_BYTES < bulkPrecision ) || (DataTypes .SHORT_VARTYPE_MAX_BYTES < destPrecision );
800
800
}
801
801
802
+ CryptoMetadata destCryptoMeta = destColumnMetadata .get (destColumnIndex ).cryptoMeta ;
803
+
802
804
/*
803
- * if source is encrypted and destination is unenecrypted use destination sql type to send since there is no way of finding if source is
804
- * encrypted without accessing the resultset, send destination type if source resultset set is of type SQLServer and encryption is enabled
805
+ * if source is encrypted and destination is unenecrypted, use destination's sql type to send since there is no way of finding if source is
806
+ * encrypted without accessing the resultset.
807
+ *
808
+ * Send destination type if source resultset set is of type SQLServer, encryption is enabled and destination column is not encrypted
805
809
*/
806
- if ((sourceResultSet instanceof SQLServerResultSet ) && (connection .isColumnEncryptionSettingEnabled ())) {
810
+ if ((sourceResultSet instanceof SQLServerResultSet ) && (connection .isColumnEncryptionSettingEnabled ()) && ( null != destCryptoMeta ) ) {
807
811
bulkJdbcType = destColumnMetadata .get (destColumnIndex ).jdbcType ;
808
812
bulkPrecision = destPrecision ;
809
813
bulkScale = destColumnMetadata .get (destColumnIndex ).scale ;
@@ -839,8 +843,7 @@ else if (((java.sql.Types.CHAR == bulkJdbcType) || (java.sql.Types.VARCHAR == bu
839
843
writeTypeInfo (tdsWriter , bulkJdbcType , bulkScale , bulkPrecision , destSSType , collation , isStreaming , srcNullable , false );
840
844
}
841
845
842
- CryptoMetadata destCryptoMeta = null ;
843
- if ((null != (destCryptoMeta = destColumnMetadata .get (destColumnIndex ).cryptoMeta ))) {
846
+ if (null != destCryptoMeta ) {
844
847
int baseDestJDBCType = destCryptoMeta .baseTypeInfo .getSSType ().getJDBCType ().asJavaSqlType ();
845
848
int baseDestPrecision = destCryptoMeta .baseTypeInfo .getPrecision ();
846
849
@@ -1268,8 +1271,13 @@ private String getDestTypeFromSrcType(int srcColIndx,
1268
1271
}
1269
1272
bulkPrecision = validateSourcePrecision (srcPrecision , bulkJdbcType , destPrecision );
1270
1273
1271
- // if encrypted source and unencrypted destination combination
1272
- if ((sourceResultSet instanceof SQLServerResultSet ) && (connection .isColumnEncryptionSettingEnabled ())) {
1274
+ /*
1275
+ * if source is encrypted and destination is unenecrypted, use destination's sql type to send since there is no way of finding if source is
1276
+ * encrypted without accessing the resultset.
1277
+ *
1278
+ * Send destination type if source resultset set is of type SQLServer, encryption is enabled and destination column is not encrypted
1279
+ */
1280
+ if ((sourceResultSet instanceof SQLServerResultSet ) && (connection .isColumnEncryptionSettingEnabled ()) && (null != destCryptoMeta )) {
1273
1281
bulkJdbcType = destColumnMetadata .get (destColIndx ).jdbcType ;
1274
1282
bulkPrecision = destPrecision ;
1275
1283
bulkScale = destColumnMetadata .get (destColIndx ).scale ;
0 commit comments