Driver version
7.4.1 (appears to be valid for other versions as well)
SQL Server version
Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64)
Aug 22 2017 17:04:49
Copyright (C) 2017 Microsoft Corporation
Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
(but appears to be valid for other versions as well)
Client Operating System
Windows 10
JAVA/JVM version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
Table schema
create table mytable (
mydata image
);
Problem description
With the fix for #611 it's now usually possible to:
- Obtain an InputStream from a BLOB with
myBlob.getBinaryStream().
- Call
myBlob.length() to get the size of the BLOB.
- Consume the InputStream.
However, if the data type of the column is image then the following exception is thrown:
Caused by: java.io.IOException: The stream is closed.
at com.microsoft.sqlserver.jdbc.BaseInputStream.checkClosed(SimpleInputStream.java:95) ~[mssql-jdbc.jar:?]
at com.microsoft.sqlserver.jdbc.SimpleInputStream.read(SimpleInputStream.java:263) ~[mssql-jdbc.jar:?]
at com.example.copyStreams(JdbcBlobStreamTester .java:41)
This happens when the value byte array in com.microsoft.sqlserver.jdbc.SQLServerBlob is null and the first active input stream isn't an instance of PLPInputStream (the call to stream.getBytes() in getBytesFromStream() causes the stream to be closed).
Reproduction code
Use the same code as in #611.
Driver version
7.4.1 (appears to be valid for other versions as well)
SQL Server version
Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64)
Aug 22 2017 17:04:49
Copyright (C) 2017 Microsoft Corporation
Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
(but appears to be valid for other versions as well)
Client Operating System
Windows 10
JAVA/JVM version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
Table schema
create table mytable (
mydata image
);
Problem description
With the fix for #611 it's now usually possible to:
myBlob.getBinaryStream().myBlob.length()to get the size of the BLOB.However, if the data type of the column is
imagethen the following exception is thrown:This happens when the
valuebyte array incom.microsoft.sqlserver.jdbc.SQLServerBlobisnulland the first active input stream isn't an instance ofPLPInputStream(the call tostream.getBytes()ingetBytesFromStream()causes the stream to be closed).Reproduction code
Use the same code as in #611.