首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

JDBC怎么读写B/CLOB

2012-01-03 
JDBC如何读写B/CLOB望高手指点!~~由于刚接触这个概念,希望能浅显易懂些!~[解决办法]Java codeStatement st

JDBC如何读写B/CLOB
望高手指点!~~由于刚接触这个概念,希望能浅显易懂些!~

[解决办法]

Java code
        Statement stmt = connection.createStatement();        ResultSet rs = stmt.executeQuery("SELECT col_blob FROM mysql_all_table");            if (rs.next()) {            // Get the BLOB from the result set            Blob blob = rs.getBlob("col_blob");                // Get the number bytes in the BLOB            long blobLength = blob.length();                // Get bytes from the BLOB in a byte array            int pos = 1;   // position is 1-based            int len = 10;            byte[] bytes = blob.getBytes(pos, len);                // Get bytes from the BLOB using a stream            InputStream is = blob.getBinaryStream();            int b = is.read(); 

热点排行