Skip to content

Commit e7dc944

Browse files
committed
Extract JDBC holdability check
1 parent 197d7fa commit e7dc944

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/main/java/org/tarantool/jdbc/SQLConnection.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.tarantool.CommunicationException;
1010
import org.tarantool.JDBCBridge;
1111
import org.tarantool.TarantoolConnection;
12+
import org.tarantool.util.JdbcConstants;
1213
import org.tarantool.util.SQLStates;
1314

1415
import java.io.IOException;
@@ -40,7 +41,6 @@
4041
import java.util.Properties;
4142
import java.util.concurrent.Executor;
4243

43-
@SuppressWarnings("Since15")
4444
public class SQLConnection implements Connection {
4545

4646
private static final int UNSET_HOLDABILITY = 0;
@@ -593,10 +593,7 @@ private void handleException(Exception e) {
593593
* @throws SQLNonTransientException param has invalid value
594594
*/
595595
private void checkHoldabilitySupport(int holdability) throws SQLException {
596-
if (holdability != ResultSet.CLOSE_CURSORS_AT_COMMIT &&
597-
holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {
598-
throw new SQLNonTransientException("", SQLStates.INVALID_PARAMETER_VALUE.getSqlState());
599-
}
596+
JdbcConstants.checkHoldabilityConstant(holdability);
600597
if (!getMetaData().supportsResultSetHoldability(holdability)) {
601598
throw new SQLFeatureNotSupportedException();
602599
}
@@ -613,4 +610,5 @@ private void checkHoldabilitySupport(int holdability) throws SQLException {
613610
private static String formatError(String sql, Object... params) {
614611
return "Failed to execute SQL: " + sql + ", params: " + Arrays.deepToString(params);
615612
}
613+
616614
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.tarantool.util;
2+
3+
import java.sql.ResultSet;
4+
import java.sql.SQLException;
5+
import java.sql.SQLNonTransientException;
6+
7+
public class JdbcConstants {
8+
9+
public static void checkHoldabilityConstant(int holdability) throws SQLException {
10+
if (holdability != ResultSet.CLOSE_CURSORS_AT_COMMIT &&
11+
holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {
12+
throw new SQLNonTransientException("", SQLStates.INVALID_PARAMETER_VALUE.getSqlState());
13+
}
14+
}
15+
16+
}

0 commit comments

Comments
 (0)