java – How to save String[] in MySQL

Question:

Hi, I would like to save a String[] in MySQL, but I don't know the type of datatype that saves String[] , nor what method I use to store this information.

Answer:

I assume you are using the Java language and JDBC for database access, but it hasn't been specified very well.

But you can do something like this: String[] array = { "java", "JDBC", "Hibernate" };

String vectorString = Arrays.toString(array); //the string will be: [java, JDBC, Hibernate]

Then saves the String vector in the bank as type VARCHAR. It's an option, but I advise you to study about ORM and object persistence.

Scroll to Top