Skip to content

Commit

Permalink
fix #124 com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractState…
Browse files Browse the repository at this point in the history
…mentAdapter.getUpdateCount error
  • Loading branch information
gaoht committed Jul 25, 2016
1 parent e542583 commit 577ae0b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ public final void setCursorName(final String name) throws SQLException {
public final int getUpdateCount() throws SQLException {
int result = 0;
for (Statement each : getRoutedStatements()) {
if (each.getUpdateCount() == -1) {
continue;
}
result += each.getUpdateCount();
}
return result;
return (result < 1) ? -1 : result;
}

@Override
Expand Down Expand Up @@ -211,7 +214,7 @@ public final ResultSet getGeneratedKeys() throws SQLException {
* 获取路由的静态语句对象集合.
*
* @return 路由的静态语句对象集合
* @throws SQLException
* @throws SQLException SQL执行异常
*/
protected abstract Collection<? extends Statement> getRoutedStatements() throws SQLException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ public void assertGetUpdateCount() throws SQLException {
assertThat(actual.getUpdateCount(), is(40));
}

@Test
public void assertGetUpdateCountNoData() throws SQLException {
actual.execute("DELETE FROM `t_order` WHERE `status` = 'none'");
assertThat(actual.getUpdateCount(), is(-1));
}

@Test
public void assertGetUpdateCountSelect() throws SQLException {
actual.execute("SELECT * FROM `t_order`");
assertThat(actual.getUpdateCount(), is(-1));
}

@Test
public void assertGetWarnings() throws SQLException {
assertNull(actual.getWarnings());
Expand Down
1 change: 1 addition & 0 deletions sharding-jdbc-doc/content/post/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ weight = 1
1. [ISSUE #36](https://github.com/dangdangdotcom/sharding-jdbc/issues/36) ShardingPreparedStatement无法反复设置参数
1. [ISSUE #114](https://github.com/dangdangdotcom/sharding-jdbc/issues/114) ShardingPreparedStatement执行批处理任务时,反复解析sql导致oom
1. [ISSUE #33](https://github.com/dangdangdotcom/sharding-jdbc/issues/33) Limit支持问题
1. [ISSUE #124](https://github.com/dangdangdotcom/sharding-jdbc/issues/124) com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractStatementAdapter.getUpdateCount返回值不符合JDBC规范

## 1.3.1

Expand Down

0 comments on commit 577ae0b

Please sign in to comment.