-1

I need to insert a JAVA String into a column in MySQL.

I'm not sure of the String's length(Could be very huge string with words, numbers and special characters like comma and full stop).

What is the recommended datatype and size of the column I must use in MySQL while creating the table ?

Nitish Vasu
  • 49
  • 2
  • 11
  • http://stackoverflow.com/questions/7071662/mysql-text-vs-blob-vs-clob you can use text if it is only text.. – sgpalit Feb 25 '16 at 12:21
  • can text store numbers and special characters ? Text stores only 64KB. Is it enough or should i use middletext ? – Nitish Vasu Feb 25 '16 at 12:24
  • 1
    I really hope you have full control over that Java source or just treat it as some arbitrary text. Otherwise you could run into serious security problems. – Thomas Feb 25 '16 at 12:24
  • Yes, I have full control over the java source. It comes from another program of mine but size of that string has no specified limit. – Nitish Vasu Feb 25 '16 at 12:26
  • Mostly 64 KB is enough but if you say that you are going to store lots of text like thousands of lines go for txt file and store its path in DB. – sgpalit Feb 25 '16 at 12:29
  • not 1000 of lines....around 100 lines – Nitish Vasu Feb 25 '16 at 12:30
  • you can store nearly 20000 characters in 64 KB, go for TEXT – sgpalit Feb 25 '16 at 12:31

2 Answers2

0

I'd use LONGTEXT for the column type. It seems to be able to store really long strings.

Actually you'll probably find more informations here: in this post

Community
  • 1
  • 1
Kevyn Meganck
  • 609
  • 6
  • 15
0

The data type could be BLOB, CLOB, or VARCHAR.

You should put this parameter with one of the PreparedStatement set... methods according to the type, for instance for a varchar statement.setString(1, someString);

Krzysztof Cichocki
  • 6,294
  • 1
  • 16
  • 32