我想更新或覆盖我的blob文件,我的图片字段在我的数据库中,我只能添加图像,但我无法更新它。如何在Java中覆盖BLOB文件
这里是我的更新域代码:
try{
String value1=txtID.getText();
String value2=txtFirst.getText();
String value3=txtLast.getText();
String value4=txtUser.getText();
String value5=txtPass.getText();
Object value6=cmbType.getSelectedItem();
Object value7=cmbStatus.getSelectedItem();
String value8=txtEmail.getText();
String sql="Update Account SET ID='"+value1+"', Fname='"+value2+"', Lname='"+value3+"',Email='"+value8+"', Username='"+value4+"', "
+ "Password='"+value5+"',Type='"+value6+"',Status='"+value7+"' WHERE ID='"+value1+"' ";
pst=conn.prepareStatement(sql);
int updateCount = pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Data has been Updated");
}
catch(SQLException e){
JOptionPane.showMessageDialog(null,e);
}
finally{
try{
rs.close();
pst.close();
}
catch(SQLException e){
JOptionPane.showMessageDialog(null,e);
}
}
}
可以有人建议代码更新或重写blobfile。
http://stackoverflow.com/questions/6189637/problems-with-update-statement-in-sqlite谷歌是你的朋友 –
这是开放[SQL注入](http://en.wikipedia.org/维基/ SQL_injection)。在SQL语句中使用'?'s,而不是将参数连接到它。 – GriffeyDog