String s1 = PasswordText4.getText();
String s2 = ConfirmText4.getText();
String s3 = NameText4.getText();
String s4 = UsernameText4.getText();
String s5 = jLabel16.getText();
if (PasswordText4.getText().equals(ConfirmText4.getText()) && s1.length() != 0 && s3.length() != 0 && s1.length() >= 4 && s2.length() >= 4) {
try {
String sql
= "BEGIN"
+ "UPDATE LOGIN SET USERNAME = ?, PASSWORD = ?, NAME = ?"
+ "WHERE USERNAME = ?;"
+ "commit;"
+ "END;";
CallableStatement cstmt = conn.prepareCall(sql);
cstmt.setString(1, UsernameText4.getText());
cstmt.setString(2, PasswordText4.getText());
cstmt.setString(3, NameText4.getText());
cstmt.setString(4, jLabel16.getText());
//System.out.println(jLabel16.getText());
int dialogButton = JOptionPane.YES_NO_OPTION;
int dialogResult = JOptionPane.showConfirmDialog(null, "Are you sure you want to update?", "Warning", dialogButton);
if (dialogResult == JOptionPane.YES_OPTION) {
cstmt.execute();
JOptionPane.showMessageDialog(null, "Information Updated");
jLabel15.setText(NameText4.getText());
jLabel16.setText(UsernameText4.getText());
jLabel17.setText(PasswordText4.getText());
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
What's wrong with this code? When I try to update my data, the Invalid SQL type:
sqlKind = UNINITIALIZED error is shown.
Please help me find solution for my problem.
Thank you in advance for answer.
BEGINUPDATE
as it is. Consider printing yoursql
String to see what's wrong. – Apply