Skip to content

Commit

Permalink
[CONJ-384] add option "useAffectedRow" test and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Jul 19, 2018
1 parent 1acc992 commit b626e02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions documentation/use-mariadb-connector-j-driver.creole
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ See [[use-mariadb-connector-j-driver.creole#using-pooling|using pooling]] for mo
|=continueBatchOnError| When executing batch queries, must batch continue on error and throw exception when ended, or stop immediately \\//Default: true. Since 1.4.0//
|=disableSslHostnameVerification| When using ssl, driver check hostname against the server's identity as presented in the server's Certificate (checking alternative names or certificate CN) to prevent man-in-the-middle attack. This option permit to deactivate this validation.\\//Default: false. Since 2.1.0//
|=autocommit|Set default autocommit value.\\//Default: true. Since 2.2.0//
|=galeraAllowedState|Usually, Connection.isValid just send an empty packet to server, and server send a small response to ensure connectivity. When this option is set, connector will ensure Galera server state "wsrep_local_state" correspond to allowed values (separated by comma). example "4,5", recommended is "4". see [galera state](http://galeracluster.com/documentation-webpages/nodestates.html#node-state-changes) to know more..\\//Default: empty. Since 2.2.5//
|=useAffectedRows|default correspond to the JDBC standard, reporting real affected rows. if enable, will report "affected" rows. example : if enable, an update command that doesn't change a row value will still be "affected", then report.\\//Default: false. Since 2.2.6//

\\\\
== Failover/High availability URL parameters
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/org/mariadb/jdbc/MultiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,22 @@ public void testInsertSelectBulk() throws SQLException {
assertEquals(5, rs.getInt(1));
assertEquals(3, rs.getInt(2));
}
}

@Test
public void testAffectedRow() throws SQLException {
createTable("testAffectedRow", "id int");
testAffectedRow(false);
testAffectedRow(true);
}

private void testAffectedRow(boolean useAffectedRows) throws SQLException {
try (Connection con = setConnection(useAffectedRows ? "&useAffectedRows" : "")) {
Statement stmt = con.createStatement();
stmt.execute("TRUNCATE testAffectedRow");
stmt.execute("INSERT INTO testAffectedRow values (1), (1), (2), (3)");
int rowCount = stmt.executeUpdate("UPDATE testAffectedRow set id = 1");
assertEquals(useAffectedRows ? 2 : 4, rowCount);
}
}
}

0 comments on commit b626e02

Please sign in to comment.