I'm trying to save an image in a postgresql table
//table schema
CREATE TABLE public.hp_xray_results
(
patient_no character varying(70),
xray_image bytea
)
java.sql.PreparedStatement pstmt = connectDB.prepareStatement("INSERT INTO hp_xray_results (patient_no,xray_image) VALUES(?,?)");
pstmt.setString(1, jTextField36.getText());
File file = new File(String.valueOf(jTable3.getValueAt(i, 4)));
FileInputStream fis=null;
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
Exceptions.printStackTrace(ex);
}
pstmt.setBinaryStream(2, fis, (int) file.length());
try {
fis.close();
} catch (IOException ex) {
ex.printStackTrace();
Exceptions.printStackTrace(ex);
}
pstmt.executeUpdate();
On running the above code, I get an exception. org.postgresql.util.PSQLException: Unable to bind parameter values for statement.
What improvements can I make?