一般情况下想将图片以二进制形式存入数据库字段我是这样做的:
第一:数据库:Db2
第二:字段类型:BLOB
第三:图片路径:Path 我这里是读取网站的图片,带http这种,这样我们就是用URL
第四:其他代码:
URL url = new URL(Path);
BufferedInputStream in = new BufferedInputStream(url.openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] temp = new byte[1024];
int size = 0;