try{is = new FileInputStream(new File(s));
PreparedStatement ps;
ps= cn.prepareStatement("Update instructor set name ='?' ,gender ='?', image ='?' where instructorID =?");
JOptionPane.showMessageDialog(null, "5");
ps.setString(1,name);
JOptionPane.showMessageDialog(null, "4");
ps.setString(2,gender);
JOptionPane.showMessageDialog(null, "3");
ps.setBlob(3, is);
JOptionPane.showMessageDialog(null, "2");
ps.setString(4, iden);
JOptionPane.showMessageDialog(null, "1");
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "successfully updated");
}catch(Exception e ){
JOptionPane.showMessage(null,"error1");
}
So I want to insert these variables to the prepared statement, however I'm getting an error. After adding those JOptionPanes to debug, the program shows "5", and then "4" and then "error1". Which I think means that the line
ps.setString(2,gender); failed to execute. However, I cannot find where did I get it wrong. Could anyone help?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…