为什么java.sql.BatchUpdateException:不唯一的表/别名:'USERS'

时间:2016-02-18 07:29:39

标签: java mysql jdbc

我想在jdbc中执行多个查询。但我得到了以下错误。我不知道为什么这样扔。请任何人帮忙解决。

我的代码:

Statement chkUserStmt = DataAccess.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

String fkcheck = "SET FOREIGN_KEY_CHECKS=0";
            String query   = "DELETE FROM USERS,ACCOUNT,ADDRESS,USEREMPLOYER,VEHICLE,USERVEHICLE "
                            +"USING USERS,ACCOUNT,ADDRESS,USEREMPLOYER,VEHICLE,USERVEHICLE"
                            +"WHERE USERS.MOBILE = ACCOUNT.MOBILE "
                            +"AND"
                            +"ADDRESS.MOBILE = USERS.MOBILE"
                            +"AND"
                            +"USEREMPLOYER.MOBILE = USERS.MOBILE"
                            +"AND"
                            +"VEHICLE.CREATEDBY = USERS.MOBILE"
                            +"AND"
                            +"USERVEHICLE.MOBILE = USERS.MOBILE"
                            +"AND"
                            +"USERS.MOBILE ='" + mobile + "'"; 
            String fkchecks = "SET FOREIGN_KEY_CHECKS=1";

            DataAccess.conn.setAutoCommit(false);
            chkUserStmt.addBatch(fkcheck);
            chkUserStmt.addBatch(query);
            chkUserStmt.addBatch(fkchecks);

            chkUserStmt.executeBatch();
            DataAccess.conn.commit();

我的错误:

Exception in thread "main" java.sql.BatchUpdateException: Not unique table/alias: 'USERS'
    at com.mysql.jdbc.Statement.executeBatch(Statement.java:961)

0 个答案:

没有答案