From 84afe48a7112aacbca281852e9a5635748c47617 Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 24 Aug 2021 17:08:23 +0800 Subject: [PATCH] change --- .../src/main/java/com/taosdata/jdbc/TSDBError.java | 1 + .../java/com/taosdata/jdbc/TSDBErrorNumbers.java | 2 ++ .../java/com/taosdata/jdbc/TSDBJNIConnector.java | 13 ++++--------- .../taosdata/jdbc/SetConfigurationInJNITest.java | 1 + 4 files changed, 8 insertions(+), 9 deletions(-) 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 977ae66515..5594dcb2e0 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 @@ -35,6 +35,7 @@ public class TSDBError { TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN_TIMESTAMP_PRECISION, "unknown timestamp precision"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_USER_IS_REQUIRED, "user is required"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_PASSWORD_IS_REQUIRED, "password is required"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_JSON_FORMAT, "invalid json format"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown error"); 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 2207db6f93..0f4427fa20 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 @@ -31,6 +31,7 @@ public class TSDBErrorNumbers { public static final int ERROR_RESTFul_Client_IOException = 0x2318; public static final int ERROR_USER_IS_REQUIRED = 0x2319; // user is required public static final int ERROR_PASSWORD_IS_REQUIRED = 0x231a; // password is required + public static final int ERROR_INVALID_JSON_FORMAT = 0x231b; public static final int ERROR_UNKNOWN = 0x2350; //unknown error @@ -72,6 +73,7 @@ public class TSDBErrorNumbers { errorNumbers.add(ERROR_RESTFul_Client_IOException); errorNumbers.add(ERROR_USER_IS_REQUIRED); errorNumbers.add(ERROR_PASSWORD_IS_REQUIRED); + errorNumbers.add(ERROR_INVALID_JSON_FORMAT); errorNumbers.add(ERROR_RESTFul_Client_Protocol_Exception); 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 f980dd041b..9c597f519b 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 @@ -49,24 +49,19 @@ public class TSDBJNIConnector { for (String key : props.stringPropertyNames()) { configJSON.put(key, props.getProperty(key)); } - int ret = setConfigImp(configJSON.toJSONString()); - if (ret == -1) { - throw TSDBError.createSQLWarning("failed to set config, invalid json format: " + configJSON.toJSONString()); - } + setConfigImp(configJSON.toJSONString()); - String configDir = props.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR); - initImp(configDir); + initImp(props.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR, null)); String locale = props.getProperty(TSDBDriver.PROPERTY_KEY_LOCALE); - String charset = props.getProperty(TSDBDriver.PROPERTY_KEY_CHARSET); - String timezone = props.getProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE); - if (setOptions(0, locale) < 0) { throw TSDBError.createSQLWarning("Failed to set locale: " + locale + ". System default will be used."); } + String charset = props.getProperty(TSDBDriver.PROPERTY_KEY_CHARSET); if (setOptions(1, charset) < 0) { throw TSDBError.createSQLWarning("Failed to set charset: " + charset + ". System default will be used."); } + String timezone = props.getProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE); if (setOptions(2, timezone) < 0) { throw TSDBError.createSQLWarning("Failed to set timezone: " + timezone + ". System default will be used."); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java index a609b21a2c..4347a37074 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java @@ -53,4 +53,5 @@ public class SetConfigurationInJNITest { e.printStackTrace(); } } + } \ No newline at end of file -- GitLab