AnsweredAssumed Answered

Uploading csv/txt and inserting data on a custom table from that file

Question asked by as0045500 on May 15, 2017
Latest reply on May 15, 2017 by as0045500

Hi Guys,

 

What i'm trying to achieve:

 

I'm creating a B2 that the user will upload a .csv and the B2 will add the file data to a custom table. It works fine when the user upload a csv file with 15k rows and 4 columns (961kb), but when i double that  the upload page redirect the user to a "file not found" page.

 

The csv that i need to upload have more then 1kk rows with 20 columns (10 int, 10 varchars). I'm using:

 

 

DiskFileItemFactory factory = new DiskFileItemFactory();

ServletFileUpload upload = new ServletFileUpload(factory);

List<FileItem> fields = upload.parseRequest(request);

Iterator<FileItem> it = fields.iterator();

 

and returning a string List of the fileItem.getString() it found. With the result, i tried two ways:

 

Creating a unique sql query string
Did each insert separately

 

Both ways are not working for larger files. In this case, what would be the best approach to insert multiple values?

Outcomes