我有这个代码可以在 MySQL 中保存图像,但它不起作用。
FileInputStream fis = null;
PreparedStatement ps = null;
MyDB.con.setAutoCommit(false);
File pic = new File(txtPicPath.getText().trim());
fis = new FileInputStream(pic);
ps = MyDB.con.prepareStatement("insert into `photo`(`Employee ID`, Picture) values (?, ?)");
ps.setString(1, Data.User.getText());
ps.setBinaryStream(2, fis, pic.length());
ps.executeUpdate();
MyDB.con.commit();
JOptionPane.showMessageDialog(rootPane, "Upload Successfully");
btnPicdelete.setEnabled(true);
btnBrowse.setEnabled(false);
btnUpload.setEnabled(false);
txtPicPass.setText("");
txtPicPath.setText("");
问题是:
java.io.FileNotFoundException: image1.jpg (The system cannot find the file specified)
我上传的图片名称是image1.jpg
.