saa*_*jil 6 java mysql sql database
我不知道这部分中的错误可以请求帮助
这是我的代码
public void addEmploye(Employe employe, Service service) throws SQLException{
int id_service = getServiceId(service);
if(nbrPersonnes(employe.getCin())!=0)
System.out.println("Employe deja existant verifier le cin");
else{
String SQL = "insert into Employe(post) "
+ "values ("
+ "'"+employe.getPost()+"')"
+ "insert into Personne(cin,nom,prenom,adresse,tel,email,password,id_directeur,id_employe,id_service)"
+ "values('"+employe.getCin()+"',"
+ "'"+employe.getNom()+"',"
+ "'"+employe.getPrenom()+"',"
+ "'"+employe.getAdresse()+"',"
+ "'"+employe.getTel()+"',"
+ "'"+employe.getEmail()+"',"
+ "'"+employe.getPassword()+"',"
+ "0,"
+ " SELECT LAST_INSERT_ID() FROM `Personne`,"
+id_service+")";
if(id_service!=0)
try {
stmt = con.createStatement();
rs = stmt.executeUpdate(SQL);
} catch (SQLException e) {
System.out.println("addEmploye "+e.toString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是错误
addEmploye com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'insert into Personne(cin,nom,prenom,adresse,tel,email,password,id_directeur,id_e' at line 1
addEmploye com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'insert into Personne(cin,nom,prenom,adresse,tel,email,password,id_directeur,id_e' at line 1
addEmploye com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'insert into Personne(cin,nom,prenom,adresse,tel,email,password,id_directeur,id_e' at line 1
addEmploye com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'insert into Personne(cin,nom,prenom,adresse,tel,email,password,id_directeur,id_e' at line 1
addEmploye com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'insert into Personne(cin,nom,prenom,adresse,tel,email,password,id_directeur,id_e' at line 1
addEmploye com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'insert into Personne(cin,nom,prenom,adresse,tel,email,password,id_directeur,id_e' at line 1
Run Code Online (Sandbox Code Playgroud)
我的teamparnter为MSSQL编写了这段代码,但我现在想在Mysql SGBD下使用它我发现这个问题任何建议请