diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 1a4ad8f050057be6e5b6d26a61720a615b84d1c7..4ee916c1842cc5080ddad8b7f70d2160f6d53cdc 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -228,11 +228,9 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn if (user == NULL) { jniTrace("jobj:%p, user is null, use default user %s", jobj, TSDB_DEFAULT_USER); - user = TSDB_DEFAULT_USER; } if (pass == NULL) { jniTrace("jobj:%p, pass is null, use default password", jobj); - pass = TSDB_DEFAULT_PASS; } /* @@ -252,8 +250,8 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn if (host != NULL) (*env)->ReleaseStringUTFChars(env, jhost, host); if (dbname != NULL) (*env)->ReleaseStringUTFChars(env, jdbName, dbname); - if (user != NULL && user != (const char *)TSDB_DEFAULT_USER) (*env)->ReleaseStringUTFChars(env, juser, user); - if (pass != NULL && pass != (const char *)TSDB_DEFAULT_PASS) (*env)->ReleaseStringUTFChars(env, jpass, pass); + if (user != NULL) (*env)->ReleaseStringUTFChars(env, juser, user); + if (pass != NULL) (*env)->ReleaseStringUTFChars(env, jpass, pass); return ret; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 6d4337e03276bdb51b5c93031fc2e2c52246b9b5..0fa841bc7cc09e64418dd721d5b148c7bec5a4b9 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -147,6 +147,8 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) { TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { tscTrace("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db); + if (user == NULL) user = TSDB_DEFAULT_USER; + if (pass == NULL) pass = TSDB_DEFAULT_PASS; STscObj* pObj = NULL; SSqlObj *pSql = taosConnectImpl(ip, user, pass, db, port, syncConnCallback, NULL, (void**) &pObj);