【发布时间】:2011-05-01 05:14:31
【问题描述】:
我正在尝试通过 jdbc 类型 4 (microsoft jdbc 3.0) 将图像文件 (.png,200KB) 插入 Sql 服务器(列类型 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 对象
每次正确时,都会插入列,但图像列保持为 NULL。
怎么了?
【问题讨论】:
标签: java sql-server sql-server-2008 jdbc