主题:写BLOB字段出现问题,解决不了 你可以在JAVA中使用DB中的类似于appendblob,getblob一类的函数来试一试。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.csdn.net/expert/topic/83/83096.shtm 你用的是什么数据库,我用oracle没出国什么问题 请问skyyoung(路人甲),如果blob或clob的数据过大,setBinaryStream(1,fis,file.length());中file.length()是int型的,长度不够怎么办? 你写的没错了,在 OutputStream os = b.getBinaryOutputStream(); os.write(byteArr); os.close(); 之前当然为null了如果是其它原因,你可以试试在插入时,给Blob字段插入一个小于4k的任意值,或是empty_blob()了 大家看一看这段代码public void writeBlob(String picID, String fileName) { File file = new File(fileName); FileInputStream fis = null; PreparedStatement ps = null; try { fis = new FileInputStream(file); ps = connection.prepareStatement("insert into pictest values (?,?)"); ps.setString(1, picID); ps.setBinaryStream(2, fis, (int)file.length()); ps.execute(); } catch (Exception e) { System.out.println("Exception at PictureDb.writeBlob: " + e); } finally { try { ps.close(); fis.close(); } catch (Exception e) { } }}出现下面的异常java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column import oracle.sql.*;BLOB b = (BLOB) rs.getBlob("pic"); ://此处取得的BLOB b总是null OutputStream os = b.getBinaryOutputStream(); os.write(byteArr); os.close(); 你的pic字段值为null估计你是用Insert into tablename(....., pic) values(....., null);这种方式插入的记录,换成Insert into tablename(....., pic) values(....., empty_blob());再次更新就不会有如下错误了! java.lang.VerifyError异常,求助! AWT-EventQueue-0"是个什么东西 JLayeredPane的急问题 system.out.printf("%3d",day)中的3是什么意思 用户登陆,连接数据库老报错.急啊!!! 这些天遇到的几个小问题,大家帮忙一起解决了吧 介绍JAVA的几本经典书籍! 谢谢!! 关于JDBC 一道SCJP的题 请问在网页中两个Applet如何互相调用 StringTokenizer 怎么用? applet里怎么连接数据库啊,jdbc好象要用到odbc,有点麻烦,有什么更好的办法吗
OutputStream os = b.getBinaryOutputStream();
os.write(byteArr);
os.close();
之前当然为null了
如果是其它原因,你可以试试在插入时,给Blob字段插入一个小于4k的任意值,或是empty_blob()了
public void writeBlob(String picID, String fileName) {
File file = new File(fileName);
FileInputStream fis = null;
PreparedStatement ps = null; try {
fis = new FileInputStream(file);
ps = connection.prepareStatement("insert into pictest values (?,?)");
ps.setString(1, picID);
ps.setBinaryStream(2, fis, (int)file.length());
ps.execute();
} catch (Exception e) {
System.out.println("Exception at PictureDb.writeBlob: " + e);
} finally {
try {
ps.close();
fis.close();
} catch (Exception e) {
}
}
}出现下面的异常
java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
BLOB b = (BLOB) rs.getBlob("pic");
://此处取得的BLOB b总是null
OutputStream os = b.getBinaryOutputStream();
os.write(byteArr);
os.close();
估计你是用Insert into tablename(....., pic) values(....., null);
这种方式插入的记录,换成
Insert into tablename(....., pic) values(....., empty_blob());
再次更新就不会有如下错误了!