我一直在搜索使用 java 在高级加密标准中执行更新查询的示例,但除了使用 AES_ENCRYPT 在 MySQL中的更新查询之外找不到任何示例?.
下面的代码起作用,但数据没有加密,我的问题是如何使用 AES_ENCRYPT 更新数据
try{
String value1 = jTextFieldID.getText();
String value2 = jTextFieldFirstname.getText();
String value3 = jTextFieldMiddlename.getText();
String value4 = jTextFieldLastname.getText();
String value5 = ((JTextField)txt_Date.getDateEditor().getUiComponent()).getText();
String value6= Gander.toString();
String value7= jTextFieldAddress.getText();
String value8 = jTextFieldCity.getText();
String value9 = jTextFieldPostcode.getText();
String sql = "update Customer set ID='"
+value1+"',FirstName='"
+value2+"',MiddleName='"
+value3+"',LastName='"
+value4+"',DOB='"
+value5+"',Gander='"
+value6+"',Address='"
+value7+"',City='"
+value8+"',PostCode='"
+value9+"'where ID='"
+value1+"'";
pst = conn.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(null, "Data is updated");
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
AES_DECRYPT
选择 ID,AES_DECRYPT(名字,'uk112')作为名字,AES_DECRYPT(中间名,'uk112')作为中间名,AES_DECRYPT(姓氏,'uk112')作为姓氏,AES_DECRYPT(出生日期,'uk112')作为 DOB,AES_DECRYPT(甘德, 'uk112' ) AS Gander, AES_DECRYPT( Address, 'uk112' ) AS Address, AES_DECRYPT( City, 'uk112' ) AS City, AES_DECRYPT( PostCode, 'uk112' ) AS PostCode FROM Customer