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

8

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

2
  • if I use varbinary, what java type should I use for java mapping of the field when i do select? byte[] or string? Jul 3, 2012 at 12:27
  • 2
    @user1379574 use byte[] (here is a link that lists type mappings). Jul 3, 2012 at 13:40
1

use a blob field

java serialblob

mysql blob

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.