updateBinaryStream on ResultSet with FileStream

Posted by Lieven Cardoen on Stack Overflow See other posts from Stack Overflow or by Lieven Cardoen
Published on 2010-04-27T13:20:40Z Indexed on 2010/04/27 13:23 UTC
Read the original article Hit count: 436

Filed under:
|
|

If I try to update a FileStream column I get following error:

com.microsoft.sqlserver.jdbc.SQLServerException: The result set is not updatable.

Code:

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();

Why is this?

Table in 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,

Query used in Java:

String strCmd = "select BinaryAssetFileId, Blob 
                 from BinaryAssets.BinaryAssetFiles 
                 where BinaryAssetFileId = 1";
stmt = con.createStatement();
rs = stmt.executeQuery(strCmd);

© Stack Overflow or respective owner

Related posts about jdbc

Related posts about sql-server