so i havebuilt my interface which is made up of a TableView which is populated from Mysql database. the database has fields as ItemID(int), ItemName(varchar)and Fil(BLOB). my tableView has an additional column called 'action' which has a download button such that when clicked, the file should be downloaded and saved in the user's prefered location. Here's the code
the problem is when i click the download button, nothing happens.FileDownloadButton.setOnAction(e -> { Item chosenItem = getTableView().getItems().get(getIndex()); File file = new File(chosenItem.getPaperName()); try { String filequery = "Select File from items Where" + "itemID" + " = " + chosenItem.getId(); PreparedStatement pst = connection.prepareStatement(filequery); ResultSet rs = pst.executeQuery(); FileOutputStream fileout = new FileOutputStream(file); while (rs.next()) { InputStream fileinput = rs.getBinaryStream("file"); byte[] buffer = new byte[1024]; while (fileinput.read(buffer) > 0) { fileout.write(buffer); } }
kindly help.
thank you