2014-03-03 38 views

回答

0

尝试此方法并解决您的疑惑。

Connection connection = DriverManager.getConnection(url, username, password); 
    Statement stmt = connection.createStatement(); 
    ResultSet rs = stmt.executeQuery("SELECT col_blob FROM mysql_all_table"); 

    if (rs.next()) { 
     Blob blob = rs.getBlob("col_blob"); 
     long blobLength = blob.length(); 

     int pos = 1; // position is 1-based 
     int len = 10; 
     byte[] bytes = blob.getBytes(pos, len); 

     InputStream is = blob.getBinaryStream(); 
     int b = is.read(); 

另一个例子just goto this link

听我说,如果你有任何疑问,应必须给我意见。

+0

谢谢,从db中检索清楚,我如何在jsp中显示它? – liron

+0

如果您想要在网页中显示图像。 – jmail

+0

是的。我想在网页 – liron

相关问题