Skip to content

Commit f5e278c

Browse files
committed
feat: fix affected rows
1 parent cefcf4e commit f5e278c

1 file changed

Lines changed: 19 additions & 22 deletions

File tree

backend/framework/src/main/java/org/jumpserver/chen/framework/datasource/base/BaseSQLActuator.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,26 @@ public int getAffectedRows(SQL sql) throws SQLException {
5656

5757
var sqlStmts = SQLUtils.parseStatements(sql.getSql(), this.druidDbType);
5858

59-
if (sqlStmts.size() != 1) {
60-
return -1;
61-
}
62-
63-
var sqlStmt = sqlStmts.get(0);
64-
65-
if (sqlStmt instanceof SQLUpdateStatement || sqlStmt instanceof SQLDeleteStatement || sqlStmt instanceof SQLInsertStatement) {
66-
var conn = this.getConnection();
67-
try {
68-
conn.setAutoCommit(false);
69-
var stmt = conn.createStatement();
70-
stmt.execute(sqlStmt.toString());
71-
72-
result = stmt.getUpdateCount();
73-
74-
conn.rollback();
75-
stmt.close();
76-
} finally {
77-
if (this.connection == null) {
78-
conn.close();
79-
} else {
80-
conn.setAutoCommit(true);
59+
for (var sqlStmt : sqlStmts) {
60+
if (sqlStmt instanceof SQLUpdateStatement || sqlStmt instanceof SQLDeleteStatement || sqlStmt instanceof SQLInsertStatement) {
61+
var conn = this.getConnection();
62+
try {
63+
conn.setAutoCommit(false);
64+
var stmt = conn.createStatement();
65+
stmt.execute(sqlStmt.toString());
66+
67+
result += stmt.getUpdateCount();
68+
69+
conn.rollback();
70+
stmt.close();
71+
} finally {
72+
if (this.connection == null) {
73+
conn.close();
74+
} else {
75+
conn.setAutoCommit(true);
76+
}
8177
}
78+
8279
}
8380
}
8481
return result;

0 commit comments

Comments
 (0)