Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Cachedrowset、JDBC和SQL server 2008插入映像问题_Java_Sql Server_Sql Server 2008_Jdbc - Fatal编程技术网

Java Cachedrowset、JDBC和SQL server 2008插入映像问题

Java Cachedrowset、JDBC和SQL server 2008插入映像问题,java,sql-server,sql-server-2008,jdbc,Java,Sql Server,Sql Server 2008,Jdbc,我正试图通过jdbc类型4(microsoft jdbc 3.0)将一个图像文件(.png,200KB)插入Sql Server(columb类型varbinary(max)),下面是我的代码: crsi.moveToInsertRow(); crsi.updateInt(1, Integer.parseInt(txt_TargetID.getText())); crsi.updateBina

我正试图通过jdbc类型4(microsoft jdbc 3.0)将一个图像文件(.png,200KB)插入Sql Server(columb类型varbinary(max)),下面是我的代码:

            crsi.moveToInsertRow();                
            crsi.updateInt(1, Integer.parseInt(txt_TargetID.getText()));
            crsi.updateBinaryStream(2, fis,f.length());
            crsi.updateString(3, txt_Name.getText());
            crsi.updateString(4, btng_Gender.getSelection().getActionCommand());
            crsi.updateString(5, dpk_Birthdate.getSelectedDateAsText());
            crsi.updateString(6, txt_IdenNo.getText());
            crsi.updateString(7, dpk_RecordDate.getSelectedDateAsText());
            crsi.insertRow();
            crsi.moveToCurrentRow();
            crsi.acceptChanges(); 
crsi是cachedrowsetimpl对象,fis是Fileinputstream对象
每次向右移动,都会插入列,但图像列保持空。
出什么问题了?

好的,我已经解决了这个问题。我应该在SQL server中启用FILESTREAM,还必须有FILESTREAM组数据库,其中必须有ROWGUID和UniqueIdentifier列。

此外,我不能使用cachedrowset上载文件流,但必须使用preparestatement上载文件流。(cachedrowset将导致同步冲突)