diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java index eeaa1d4df544d7e91bdaa7093badf3bd5f4beb07..c7717e331b39247542d1a022cafd1cab2ac65627 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java @@ -31,8 +31,8 @@ public class TSDBError { TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING, "Unsupported encoding"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_TDENGINE_ERROR, "internal error of database"); - TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL, "JNI connection already closed"); - TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL, "invalid JNI result set"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL, "JNI connection is NULL"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL, "JNI result set is NULL"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0, "invalid num of fields"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_SQL_NULL, "empty sql string"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_FETCH_END, "fetch to the end of resultSet"); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java index 2003229a3a975d32705f75a1e86b6b4235343ab3..3ae8696f7d3931160ab55f31064839b33a9ceecd 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java @@ -25,7 +25,7 @@ public class TSDBErrorNumbers { public static final int ERROR_UNSUPPORTED_ENCODING = 0x2352; // Unsupported encoding public static final int ERROR_JNI_TDENGINE_ERROR = 0x2353; // internal error of database - public static final int ERROR_JNI_CONNECTION_NULL = 0x2354; // JNI connection already closed + public static final int ERROR_JNI_CONNECTION_NULL = 0x2354; // JNI connection is NULL public static final int ERROR_JNI_RESULT_SET_NULL = 0x2355; // invalid JNI result set public static final int ERROR_JNI_NUM_OF_FIELDS_0 = 0x2356; // invalid num of fields public static final int ERROR_JNI_SQL_NULL = 0x2357; // empty sql string diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index 68905938c3507b2873d798b591d81cd222f2bfb6..f3c4e025798e8e3fd8db0e5c1a1b25aa6fea3dc7 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -102,7 +102,7 @@ public class TSDBJNIConnector { this.taos = this.connectImp(host, port, dbName, user, password); if (this.taos == TSDBConstants.JNI_NULL_POINTER) { - throw TSDBError.createSQLException(this.getErrCode(0l), this.getErrMsg(0L)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); } // invoke connectImp only here taosInfo.conn_open_increment(); @@ -273,7 +273,7 @@ public class TSDBJNIConnector { public void closeConnection() throws SQLException { int code = this.closeConnectionImp(this.taos); if (code < 0) { - throw TSDBError.createSQLException(this.getErrCode(0l), this.getErrMsg(0L)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); } else if (code == 0) { this.taos = TSDBConstants.JNI_NULL_POINTER; } else { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java index 3fcdcf55fe5f133eeff89afc5f298c8ef2c7e1f7..875368d17e0114f80e72fc45f25a2352131dcd72 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java @@ -16,7 +16,7 @@ public class ConnectWrongDatabaseTest { } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { - Assert.assertEquals(-2147482749, e.getErrorCode()); + Assert.assertEquals(-2, e.getErrorCode()); } }