Netbeans를 사용하여 내 테이블의 필드를 업데이트하려고합니다.MySQL의 SyntaxErrorException에 대한 업데이트 쿼리
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/student_reg";
try {
Class.forName(driver);
Connection con = DriverManager.getConnection(url,"user","abc");
PreparedStatement state = con.prepareStatement("UPDATE supplier SET sname='" + txtname.getText()+"' , add='"+txtadd.getText()+"' WHERE sid ='" +txtid.getText() + "'");
state.executeUpdate();
JOptionPane.showMessageDialog(null, "Your Record sucessfully Updated");
}catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
}
을하지만, 나는 다음과 같은 오류가 점점 오전 :
com.mysql.jdbc.exceptions.jdbc4.MySQL SyntaxErrorException
:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add=kegalle'where sid=001" at line 1
내가 그것을 어떻게 해결할 수를 다음과 같이 업데이트 문은 무엇입니까?
당신은 ... 설정하지 왜 PerparedStatement (..) 대신에 일반 텍스트의 호출을 사용하는 경우? – kosa