Reputation: 1
I'm confused about the SQL String query in method below. It shows absolutely correct and despite who rows created in oracle database, threw the following exception: ORA-0933: command not properly ended. I try to find the solution but without result.
What is going wrong? Can you help me?
Thank you in advance and sorry for any bad English.
public void insertMemberAction() {
String query = "INSERT INTO MEMBERS VALUES(" + jMnoTxt.getText() + ", '" +
jLastnameTxt.getText() + "', '" + jFirstnameTxt.getText() + "', '" +
jAddressTxt.getText() + "', '" + jRegistrationDateTxt.getText() + "')";
java.sql.Statement insertStmt;
try {
insertStmt = DvdClubJFrame.con.createStatement();
insertStmt.executeUpdate(query);
insertStmt.close();
} catch (java.sql.SQLException e) {
javax.swing.JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Upvotes: 0
Views: 322
Reputation: 433
Use PreparedStatements, or escape your parameters using apache common's StringEscapeUtils
Upvotes: 1