I have worked on saving a single file into database(postgresql) and it works fine. But I am stuck when i try to upload multiple files.
My jsp fileupload :
<input type="file" id="reqFile" name="attachments.myFile" multiple/>
This is my action method :
    public String SaveAttachments() throws SQLException, IOException {
    int case_id = (Integer) session.get("case_id");
    System.out.println("in save attachments()");
    int uploaded_by = 1;
    try {
        File destFile = new File(attachments.getMyFileFileName());
        FileUtils.copyFile(attachments.getMyFile(), destFile);
        fis = new FileInputStream(destFile);
        currentCon = ConnectionManager.getConnection();
        pstmt = (PreparedStatement) currentCon.prepareStatement("insert into case_attachments(case_id, attachment, attachment_title, upload_date, uploaded_by) values(?,?,?,current_date,?)");
        pstmt.setInt(1, case_id);
        pstmt.setBinaryStream(2, fis, (int) destFile.length());
        pstmt.setString(3, attachments.getMyFileFileName());
        pstmt.setInt(4, uploaded_by);
        pstmt.executeUpdate();
    } catch (Exception e) {
        System.out.println("Error From SaveAttachments :" + e);
    }
    return SUCCESS;
}
When I attach multiple files it goes into the same column in database in comma seperated format. How can i save files in different rows when the user attaches multiple files? Thanks In advance.
 
     
     
     
    