하나의 속성, 이름을 가진 학생을 추가하려고 할 때 오류가 발생합니다. 오류 :학생을 데이터베이스에 추가 할 때 오류가 발생했습니다.
SQL 구문에 오류가 있습니다. 라인 1
오류가이 코드를 지적에 ') 근처의'이름 '을 사용할 수있는 권리 구문에 대한 MySQL 서버 버전에 해당하는 설명서,
//Class DAL
public int addStudent(String name)throws SQLException{
PreparedStatement studentStatement = getConnected().prepareStatement("insert into person" + "values (?)") ;
studentStatement.setString(1,name);
//This is highlighted by the error
int rSetStudent = studentStatement.executeUpdate();
return rSetStudent;
}
//Class controller
public int addStudent(String name) throws SQLException{
//This is highlighted
return dal.addStudent(name);
}
//and this in class MainFrame where i use the add method from controller class
//this is highlighted
private void addStudent(){
try{
//and this
int a = controller.addStudent(nameTxtField.getText().trim());
}catch(SQLException e){
e.printStackTrace();
}
}
방법을 확인 addStudent()
버튼 을 추가하면을 클릭 할 때 호출됩니다. 누군가 MySql을 사용하고 있는지 궁금하다면.
이것 역시 효과가 있으며 더 정확하게 보입니다. 나는 이것을 대답으로 표시 할 것이다. – Eskipo
@Eskipo 두 번째 방법을 사용하는 것이 좋습니다. – SpringLearner
"i"+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ " + ": D" – Andy