From 2e2767c0ee64cee1ffc8ba66f2978a92a74bb078 Mon Sep 17 00:00:00 2001 From: zyyang Date: Sat, 20 Feb 2021 15:19:02 +0800 Subject: [PATCH] change --- .../java/com/taosdata/jdbc/AbstractConnection.java | 12 ++++++++++++ .../java/com/taosdata/jdbc/TSDBConnectionTest.java | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java index d3aa0975d2..5c34320320 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java @@ -109,6 +109,18 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti public void setTransactionIsolation(int level) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); + + switch (level) { + case Connection.TRANSACTION_NONE: + break; + case Connection.TRANSACTION_READ_UNCOMMITTED: + case Connection.TRANSACTION_READ_COMMITTED: + case Connection.TRANSACTION_REPEATABLE_READ: + case Connection.TRANSACTION_SERIALIZABLE: + throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG); + default: + throw new SQLException(TSDBConstants.INVALID_VARIABLES); + } //do nothing } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java index f4cb05c8ff..5fd9578957 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java @@ -122,6 +122,7 @@ public class TSDBConnectionTest { @Test public void getCatalog() throws SQLException { + conn.setCatalog("log"); Assert.assertEquals("log", conn.getCatalog()); } @@ -129,7 +130,6 @@ public class TSDBConnectionTest { public void setTransactionIsolation() throws SQLException { conn.setTransactionIsolation(Connection.TRANSACTION_NONE); Assert.assertEquals(Connection.TRANSACTION_NONE, conn.getTransactionIsolation()); - conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); } @@ -238,7 +238,7 @@ public class TSDBConnectionTest { int status = rs.getInt("server_status()"); Assert.assertEquals(1, status); - conn.prepareStatement("select server_status", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); + conn.prepareStatement("select server_status", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); } @Test(expected = SQLFeatureNotSupportedException.class) -- GitLab