The difference between storing images in a byte array and binary (BLOB), and which is faster

I want to insert and select images from sql server in jdbc. I am confused if the BLOBs and bytes are the same or different. I used Blob in my code, and the application loads slowly, because it needs to select the images stored in Blob and convert them to pixels. I want to use an array of bytes, but I don't know if they are the same or different. My main goal is to load the image faster. Thanks you

+9
source share
2 answers

Usually LOB and BLOB are confused. Here are the options:

, . .

0

, , , , BLOB.

: . . 0 1.

: , ( , ). .

: , , 0 1.

BLOB: , . , , .

: - , .

, .

import java.nio.ByteBuffer;

public class TestByteAndBinary{

     public static void main(String []args){
        String s = "test"; //a string, series of chars
        System.out.println(s);

        System.out.println();

        byte[] bytes = s.getBytes(); //since each char has a size of 1 byte, we will have an array which has 4 elements
        for(byte b : bytes){
            System.out.println(b);
        } 

        System.out.println();

        for(byte b : bytes){
            String c = String.format("%8s", Integer.toBinaryString(b)).replace(' ', '0'); //each element is printed in its binary format
            System.out.println(c);
        }
     }
}

:

$javac TestByteAndBinary.java
$java -Xmx128M -Xms16M TestByteAndBinary
test

116
101
115
116

01110100
01100101
01110011
01110100

: , BLOB.

! .

  • , .

  • - . ( , ).

  • , , .

  • ( )

.

, . , , . , .

0

All Articles