MySQL에서 이미지를 저장하는 데이 코드가 있지만 작동하지 않습니다.이미지를 MySQL에 Blob로 저장하십시오.
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
입니다.
오류가 분명히 말한다 '시스템 파일 specified'을 찾을 수 없습니다. 지정된 경로에 image1.jpg이 있습니까? –
이미지 경로가 올바른지 또는 올바른 디렉토리에 파일을 넣었는지 확인하십시오. – Ankit
파일의 전체 경로를 지정하십시오. 또한 존재하는지 확인하십시오. –