Em đang tập lập trình JAVA Swing với Sql
MÀ BỊ LỖI: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '? Và Tên, ??a Ch?, ?i?n Tho?i, S? ti?n ?ã thanh toán) VALUES (‘DA’, ‘DA’, ‘D’ at line 1
Đoạn code em kết nối với database:
if( operation =='i')
{
try {
ps= con.prepareStatement("INSERT INTO lblquanlyktx( MSSV, Họ Và Tên, Địa Chỉ, Điện Thoại, Số tiền đã thanh toán) VALUES (?, ?, ?, ?, ?)");
ps.setString(1, mssv);
ps.setString(2, hovaten);
ps.setString(3, diachi);
ps.setString(4, dienthoai);
ps.setString(5, tien);
if(ps.executeUpdate() >0) {
JOptionPane.showMessageDialog(null, "new student added");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Còn đoạn này, em cho nó vào trong nút Add
public void actionPerformed(ActionEvent e) {
String mssv= txtmssv.getText();
String hovaten= txthovaten.getText();
String diachi= txtdiachi.getText();
String dienthoai= txtdienthoai.getText();
String tien= txtthanhtoan.getText();
Student ku= new Student();
ku.themSuaXoa('i', null, mssv, hovaten, diachi, dienthoai, tien);
}
});