18

I have a byte array created in Java. It represents content of some file. I don't know exactly the maximum size of this array. It can be different sizes. I want to store it in mysql. What type should I use in mysql?

3 Answers 3

25

Use BLOB, medium blob , varbinary

Mysql Choosing the Right Type for a Column

Sign up to request clarification or add additional context in comments.

Comments

8

Use varbinary to store byte arrays of arbitrary length in MySQL.

2 Comments

if I use varbinary, what java type should I use for java mapping of the field when i do select? byte[] or string?
@user1379574 use byte[] (here is a link that lists type mappings).
1

use a blob field

java serialblob

mysql blob

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.