I have a java application with apache-poi 3.5
.
My database is Microsoft Sql Server
.
In my application i do an upload and i want to know if it's possible to store my file (*.xls
, *.csv
, *.xlsx
) directly in my database ?
I have a java application with apache-poi 3.5
.
My database is Microsoft Sql Server
.
In my application i do an upload and i want to know if it's possible to store my file (*.xls
, *.csv
, *.xlsx
) directly in my database ?
You could consider converting the files to their binary equivalent (a byte[]
) and using a VARBINARY(MAX)
field to store the contents as well as the file name so that you could properly reconstruct the file) :
// Retrieve the byte[] data for your file
byte[] data = Files.readAllBytes(new File("/path/to/file").toPath());
// Write this data to a VARBINARY(MAX) field in SQL here
There are a variety of approaches to handle this, but this would be the most naive approach.