how to import a csv file into a mysql from an hibernate+spring application?
i want to do an import of a csv file into a mysql table. The reason im doing an import is becuase i have many big files, that are sent to my server in short intervals, tried with java adding line by line, but got a bunch of different errors, like hibernate exceptions or java hung if the file was too big. Imports works very fast, very well with very little resources. But i don´t know how can i build a query through hibernate's HQL to do this, something like:
LOAD DATA INFILE '"+filename+ "' INTO TABLE testtable (text,price);
if this can´t be done, then how can i run a shellscript from the method that do this ?
Not sure I have enough information to fully answer your question, but Hibernate's Native Query facilities might let you load a file that way.
session.createSQLQuery("LOAD DATA INFILE :filename INTO TABLE testtable (text,price)").setString("filename", "/path/to/MyFile.csv").executeUpdate();
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]