Skip to content

Commit

Permalink
[misc] remove 2 unnecessary exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Jan 9, 2016
1 parent f48531b commit 6d156a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
16 changes: 7 additions & 9 deletions src/main/java/org/mariadb/jdbc/MariaDbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,14 @@ public void setAutoCommit(boolean autoCommit) throws SQLException {
public void commit() throws SQLException {
lock.lock();
try {
if (getAutoCommit()) {
throw new SQLException("Error : committing transaction on a autocommit connection", "HY012");
}
Statement st = createStatement();
try {
st.execute("COMMIT");
} finally {
st.close();
if (!getAutoCommit()) {
Statement st = createStatement();
try {
st.execute("COMMIT");
} finally {
st.close();
}
}

} finally {
lock.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,6 @@ public void lockAndSwitchSecondary(Protocol newSecondaryProtocol) throws QueryEx
*/
@Override
public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryException {
if (mustBeReadOnly != currentReadOnlyAsked && currentProtocol.inTransaction()) {
throw new QueryException("Trying to set to read-only mode during a transaction");
}
checkWaitingConnection();
if (currentReadOnlyAsked != mustBeReadOnly) {
proxy.lock.lock();
Expand Down

0 comments on commit 6d156a1

Please sign in to comment.