blob type

1.BLOB  
BLOB stands for Binary Large Object. It is used to store large binary objects in the database. The maximum size that can be stored is 4G bytes  
. 2.CLOB  
CLOB is called Character Large Object. It is similar to the LONG data type, except that CLOB is used to store large single-byte character data blocks in the database and does not support character sets of different widths. The maximum size that can be stored is 4G bytes.

     Usually, information such as pictures, files, and music are stored in the BLOB field, and the files are first converted into binary and then stored. For articles or longer texts, CLOB is used to store them, which provides great convenience for future queries, updates, storage, and other operations.


/**
     * <Convert the string into a byte array and then encapsulate it into a string>
     * <Function detailed description>
     * @param chinese
     * @return
     * @see [class, class #method, class #member]
     */ 
    public static String chineseToString(String chinese) 
    { 
        if (Global.isEmpty(chinese)) 
        { 
            return ""; 
        } 
        else 
        { 
            // Define StringBuffer 
            StringBuffer sb = new StringBuffer(); 
             
            // Convert the incoming string to byte array 
            byte[] b = chinese.getBytes(); 
             
            byte[] temp = null; 
             
            // traverse the byte array , convert byte array to string 
            for (int i = 0; i < b.length; i++) 
            { 
                temp = new byte[4]; 
                temp[0] = b[i]; 
                temp[1] = 0; 
                temp[2] = 0; 
                temp[3] = 0; 
                sb.append(lBytesToInt(temp)); 
                if (i < b.length - 1) 
                { 
                    sb.append("@"); 
                } 
            } 
             
            return sb.toString(); 
        } 
    } 
     
    /**
     * <Convert the string encapsulated by the byte array into the original string>
     * <Function detailed description>
     * @param stc
     * @return
     * @see [class , class#method, class#member]
     */ 
    public static String stringToChinese(String stc) 
    { 
        // If the passed string is empty, return empty directly 
        if (Global.isEmpty(stc)) 
        { 
            return ""; 
        } 
        else 
        { 
            // split string 
            String[] s = stc.split("@"); 
            if (s.length > 0) 
            { 
                // Loop to construct BYTE array 
                byte[] b = new byte[s.length]; 
                for (int i = 0; i < s.length; i++) 
                { 
                    b[i] = (byte)Integer.parseInt(s[ i]); 
                } 
                 
                // Construct string from BYTE array 
                return new String(b); 
            } 
            else 
            { 
                return ""; 
            } 
        } 
    } 
     
    /**
     * Convert low byte array to int
     * @param b byte[]
     * @return int
     */ 
    public static int lBytesToInt(byte[] b) 
    { 
        int s = 0; 
        for (int i = 0; i < 3; i++) 
        { 
            if (b[3 - i] >= 0) 
            { 
                s = s + b[3 - i]; 
            } 
            else 
            { 
                s = s + 256 + b[3 - i]; 
            } 
            s = s * 256; 
        } 
        if (b[0] >= 0) 
        { 
            s = s + b[0]; 
        } 
        else 
        { 
            s = s + 256 + b[0]; 
        } 
        return s; 
    } 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326989593&siteId=291194637