日期:2014-05-20 浏览次数:21044 次
try {
    java.net.URL url = new URL(weburl);//创建URL连接
    URLConnection uc = url.openConnection();    
    InputStream is = uc.getInputStream();
    String sql = "insert into zc(tupian) values(?)";
    pst = conn.prepareStatement(sql);
    pst.setBinaryStream(1,is);
    pst.executeUpdate();
    s.close(); 
} catch (Exception e) {
    System.out.println("页面没有找到!");
    }
INSERT into zc(tupian) values(LOAD_FILE('D:\1.jpg'));
------解决方案--------------------
你的是网络上的资源还是本地的,Mysql一般存得是图片地址,Oracal才会存二进制。给你找的一篇文章http://eric-gcm.iteye.com/blog/937860
------解决方案--------------------
直接保存网络上的资源还真没试过,LZ可以试着先把图片下到本地,再存入数据库,之后再把本地的图片删掉
------解决方案--------------------
MySQL的四种BLOB类型
   类型               大小(单位:字节)
  TinyBlob          最大 255
  Blob              最大 65K
  MediumBlob        最大 16M
  LongBlob          最大 4G
所以用BLOB时,图片大小如果大于65K就会出错