Java implementation of accessing image operation examples with MySQL

1. Blob type in MySQL

MySQL can store large file data, generally using blob objects. Such as pictures, videos and so on.

Blob is a large binary object that can hold a variable amount of data. Because it is a binary object, it has nothing to do with the encoding method. There are four types of blobs: tinyblob, blob, mediablob and longblob. They differ only in the maximum length of the value that can be accommodated.

The maximum length of the four field types is as follows:

The following is the phototest table structure defined in the test database.

The code for saving and reading pictures is as follows:

3. Select the appropriate field size

If the maximum length of the selected field type is too small to hold the saved data, a MySQL data truncation exception may be reported. For example:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>