나는 7 열과 첫 번째 여섯 열, 저장 문자열 유형 있지만 마지막 한 스토어 BLOB type.I addBirth 메서드와 그 6 문자열 유형을 얻을 마지막 열에 대한 이미지를 저장하는 SQL 테이블을 가지고, 나는 insertImageToBirthTable 방법. 사용자가 사람을 추가하기 위해 사진을 선택하지 않았기 때문에 문자열과 BLOB를 함께 저장하고 싶지 않습니다. (내 게시물을 편집했지만이 방법을 사용하여 이미지를 저장했지만 여전히 SQL 테이블에 null 값이 있습니다. 왜 ???) 또한 pathfile을 인쇄했는데 null이 아니 었습니다.어떻게 일곱 번째 열에 이미지를 설정할 수 있습니까?
내 insertImageToBirthTable 방법 :
공공 정적 무효 insertImageToBirthTable (문자열 이름, 문자열 가족, 문자열 fatherName, 문자열 motherName, 문자열 생년월일 (DateOfBirth), 문자열 placeOfBirth, 문자열 pathFile) {
try {
System.out.println(pathFile);
File file = new File(pathFile);
FileInputStream input = new FileInputStream(file);
PreparedStatement stmt = (PreparedStatement) conn.prepareStatement("UPDATE birthtable SET image =? WHERE name = '" + name + "'AND family ='" + family + "'AND fatherName = '" + fatherName + "'AND motherName ='" + motherName + "' AND dateOfBirth = '" + dateOfBirth + "' AND placeOfBirth = '" + placeOfBirth + "'");
stmt.setBinaryStream(1, input);
stmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
Ohoh, 내 이름은 null입니다. "> – Johanna