如果我嘗試更新FILESTREAM字段我獲得以下錯誤:updateBinaryStream上的ResultSet使用FileStream
com.microsoft.sqlserver.jdbc.SQLServerException:結果集是不可更新。
代碼:
System.out.print("Now, let's update the filestream data.");
FileInputStream iStream = new FileInputStream("c:\\testFile.mp3");
rs.updateBinaryStream(2, iStream, -1);
rs.updateRow();
iStream.close();
這是爲什麼?
表在SQL Server 2008:
CREATE TABLE [BinaryAssets].[BinaryAssetFiles](
[BinaryAssetFileId] [int] IDENTITY(1,1) NOT NULL,
[FileStreamId] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[Blob] [varbinary](max) FILESTREAM NULL,
[HashCode] [nvarchar](100) NOT NULL,
[Size] [int] NOT NULL,
[BinaryAssetExtensionId] [int] NOT NULL,
查詢在Java中使用:
String strCmd = "select BinaryAssetFileId, Blob
from BinaryAssets.BinaryAssetFiles
where BinaryAssetFileId = 1";
stmt = con.createStatement();
rs = stmt.executeQuery(strCmd);