I have an application where I am going to store the JSON string in MySql database through Eclipselink JPA. The JSON string can be of any length. Most of the time a String from a JSON file of length around 200 to 300 lines. What is the best way to store the string? To use varchar or Blob? Please provide an example if any.
            Asked
            
        
        
            Active
            
        
            Viewed 623 times
        
    2 Answers
1
            
            
        You should not save it as a BLOB, as it is primarily used for image data or other binary data... Use Varchar() or use TEXT which has a size of 65535 characters if you are unsure about how many characters you might need to store..
There was a thread previously discussing WHEN to use varchar or text: Thread
1
            
            
        To store text - use a TEXT column (or even a LONGTEXT), blobs are for binary.
Also if you're on Mysql 5.7+ - there's now a JSON data type, which is checked for being a correct json, stored more efficiently and have pretty manipulation methods
 
    
    
        Vasfed
        
- 18,013
- 10
- 47
- 53
- 
                    But does eclipselink support MySQL 5.7's `JSON` type? – gammay Aug 17 '17 at 12:59
 
     
    