四个本问题的贴子至今没有任何人可以回答,全部都是可以啊,行啊,没问题啊
没有任何代码证明我的信箱是 [email protected]
收到可行代码立刻结贴送分
http://community.csdn.net/Expert/topic/3638/3638776.xml?temp=.6011927
http://community.csdn.net/Expert/topic/3637/3637320.xml?temp=.0927698
http://community.csdn.net/Expert/topic/3638/3638807.xml?temp=.9520227
http://community.csdn.net/Expert/topic/3638/3638773.xml?temp=.4013636

解决方案 »

  1.   

    use BLOB data type rather than binary type.
      

  2.   

    下面是我在一个应用中java处理图片的(根据你测试改动了一些,注意在java文件中import java.sql.Statement等包,假定图像表tab_photo包含字段: 图像id 自增型,图像photo LONGBLOB),我用的是postgresql的数据库,不过mysql也应该是一样的,因为数据库中图片存储的都是二进制对象,你自己测试下吧。String url =  "jdbc:mysql://127.0.0.1/test?user=test&password=123456";
    Connection conn = DriverManager.getConnection(url,"test","123456");;
    PreparedStatement statement = null;String photo="你数据库服务器上图片的完整地址(比如/tmp/test.jpg,不在服务器的要上传,可以利用jsp smartupload或struts等)";
    File file = new File(photo);
    FileInputStream fis = new FileInputStream(file);
    int fileLength = (int)file.length(); 
    photoStr = "insert into tab_photo(photo) values(?)";
    statement = conn.prepareStatement(photoStr);
    statement.setBinaryStream(1, fis, fileLength);
    statement.executeUpdate();
    statement.close();
    fis.close();