⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e256. getting blob data from a database table.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
A BLOB is a reference to data in a database. This example demonstrates how to retrieves bytes from a BLOB. 
    try {
        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();
        }
    } catch (IOException e) {
    } catch (SQLException e) {
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -