I have a Java program which will produce a large matrix, at the end I want to save that matrix to a DATABASE 'MYDATABASE' in a myMatrixTable
My first thoughts as newbie were
StringBuilder mtrx and make large string with all data then executeUpdate(mtrx.toString()); is there a better way to save a matrix ?
If the matrix is very big, another option would be to write it into a file, then use LOAD DATA INFILE syntax to load it to the DB. This gives better performance for large sets of data.
See manual here: http://dev.mysql.com/doc/refman/5.1/en/load-data.html
EDIT:
In case the matrix is small (not many rows), I would go for the first option, looping over the rows and using INSERT, which is way more elegant and readable than the second option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With