Gurmeet singh
Gurmeet singh

Reputation: 15

How to save data of unknown length in mysql or any database

i am making a chatting software in java in which the chats are to be stored in the database but how the chats of different size can be stored in it.

Upvotes: 1

Views: 961

Answers (2)

wafaa hegazy
wafaa hegazy

Reputation: 97

there are many types that can store a large amount of data like

TINYTEXT 256 bytes

TEXT 65,535 bytes ~64kb

MEDIUMTEXT 16,777,215 bytes ~16MB

LONGTEXT 4,294,967,295 bytes ~4GB

or you can use BLOB to store data as file ,i hope this example will help Insert file data into MySQL database using JDBC example

Upvotes: 0

Sanjeet Kumar
Sanjeet Kumar

Reputation: 26

I would suggest you to use text file locally for saving chat histories and sync that text file in database in BLOB field. using stream writers you can easily retrieve through saved data.

Best luck, Happy coding

Upvotes: 1

Related Questions