Java Cachedrowset、JDBC和SQL server 2008插入映像问题
我正试图通过jdbc类型4(microsoft jdbc 3.0)将一个图像文件(.png,200KB)插入Sql Server(columb类型varbinary(max)),下面是我的代码: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
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将导致同步冲突)