Driver version
mssql-jdbc-8.4.0.jre11.jar
SQL Server version
Microsoft SQL Server 2017 (RTM-GDR) (KB4505224) - 14.0.2027.2 (X64) Jun 15 2019 00:26:19 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
Client Operating System
Windows 10
JAVA/JVM version
RedHat OpenJDK
openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)
Table schema
CREATE TABLE [dbo].[TEST](
[name] [varchar](10) COLLATE Japanese_CS_AS_KS_WS NOT NULL
)
Problem description
-
Expected behaviour:
One row has been bulk-inserted.
-
Actual behaviour:
SQL Exception occured.
-
Error message/stack trace:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: (... (Japanese message))
-
Any other details that can be helpful:
In SQLBulkCopy.java, Line Around 2292 (commit-id 4e3ab66):
2292: tdsWriter.writeShort((short) (colValueStr.length()));
I think the above code should be something like this:
tdsWriter.writeShort((short) (colValueStr.getBytes(destColumnMetadata.get(destColOrdinal).collation.getCharset()).length));
when destCollation is not null.
Because colValueStr.length() is different from the transferred byte size by tdsWriter.writeBytes();
Bulk.java.txt
Driver version
mssql-jdbc-8.4.0.jre11.jar
SQL Server version
Microsoft SQL Server 2017 (RTM-GDR) (KB4505224) - 14.0.2027.2 (X64) Jun 15 2019 00:26:19 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
Client Operating System
Windows 10
JAVA/JVM version
RedHat OpenJDK
openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)
Table schema
Problem description
Expected behaviour:
One row has been bulk-inserted.
Actual behaviour:
SQL Exception occured.
Error message/stack trace:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: (... (Japanese message))
Any other details that can be helpful:
In SQLBulkCopy.java, Line Around 2292 (commit-id 4e3ab66):
I think the above code should be something like this:
tdsWriter.writeShort((short) (colValueStr.getBytes(destColumnMetadata.get(destColOrdinal).collation.getCharset()).length));when destCollation is not null.
Because colValueStr.length() is different from the transferred byte size by tdsWriter.writeBytes();
Bulk.java.txt