change
This commit is contained in:
parent
faa7a55598
commit
9a58d6d893
|
@ -24,49 +24,45 @@ public class TSDBError {
|
|||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE, "not a valid sql for execute: (?)");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "parameter index out of range");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED, "connection already closed");
|
||||
|
||||
/**************************************************/
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown error");
|
||||
/**************************************************/
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_SUBSCRIBE_FAILED, "failed to create subscription");
|
||||
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_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");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY, "JNI alloc memory failed!");
|
||||
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_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");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY, "JNI alloc memory failed");
|
||||
}
|
||||
|
||||
public static String wrapErrMsg(String msg) {
|
||||
return "TDengine Error: " + msg;
|
||||
}
|
||||
|
||||
public static SQLException createSQLException(int errorNumber) {
|
||||
return createSQLException(errorNumber, null);
|
||||
}
|
||||
|
||||
public static SQLException createSQLException(int errorNumber, String message) {
|
||||
if (message == null || message.isEmpty() || message.replaceAll("\\s", "").isEmpty()) {
|
||||
if (TSDBErrorNumbers.contains(errorNumber))
|
||||
message = TSDBErrorMap.get(errorNumber);
|
||||
public static SQLException createSQLException(int errorCode) {
|
||||
String message;
|
||||
if (TSDBErrorNumbers.contains(errorCode))
|
||||
message = TSDBErrorMap.get(errorCode);
|
||||
else
|
||||
message = TSDBErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
|
||||
return createSQLException(errorCode, message);
|
||||
}
|
||||
// throw SQLFeatureNotSupportedException
|
||||
if (errorNumber == TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD)
|
||||
return new SQLFeatureNotSupportedException(message, "", errorNumber);
|
||||
// throw SQLClientInfoException
|
||||
if (errorNumber == TSDBErrorNumbers.ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED)
|
||||
return new SQLClientInfoException(message,null);
|
||||
|
||||
if (errorNumber < TSDBErrorNumbers.ERROR_UNKNOWN)
|
||||
public static SQLException createSQLException(int errorCode, String message) {
|
||||
// throw SQLFeatureNotSupportedException
|
||||
if (errorCode == TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD)
|
||||
return new SQLFeatureNotSupportedException(message, "", errorCode);
|
||||
// throw SQLClientInfoException
|
||||
if (errorCode == TSDBErrorNumbers.ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED)
|
||||
return new SQLClientInfoException(message, null);
|
||||
|
||||
if (errorCode > 0x2300 && errorCode < 0x2350)
|
||||
// JDBC exception's error number is less than 0x2350
|
||||
return new SQLException("ERROR (" + Integer.toHexString(errorNumber) + "): " + message, "", errorNumber);
|
||||
return new SQLException("ERROR (" + Integer.toHexString(errorCode) + "): " + message, "", errorCode);
|
||||
if (errorCode > 0x2350 && errorCode < 0x2400)
|
||||
// JNI exception's error number is large than 0x2350
|
||||
return new SQLException("TDengine ERROR (" + Integer.toHexString(errorNumber) + "): " + message, "", errorNumber);
|
||||
return new SQLException("JNI ERROR (" + Integer.toHexString(errorCode) + "): " + message, "", errorCode);
|
||||
return new SQLException("TDengine ERROR (" + Integer.toHexString(errorCode) + "): " + message, "", errorCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,24 +13,24 @@ public class TSDBErrorNumbers {
|
|||
public static final int ERROR_INVALID_WITH_EXECUTEQUERY = 0x2307; //Can not issue data manipulation statements with executeQuery()
|
||||
public static final int ERROR_INVALID_WITH_EXECUTEUPDATE = 0x2308; //Can not issue SELECT via executeUpdate()
|
||||
public static final int ERROR_INVALID_FOR_EXECUTE_QUERY = 0x2309; //not a valid sql for executeQuery: (SQL)
|
||||
public static final int ERROR_DATABASE_NOT_SPECIFIED_OR_AVAILABLE = 0x2310; //Database not specified or available
|
||||
public static final int ERROR_INVALID_FOR_EXECUTE_UPDATE = 0x2311; //not a valid sql for executeUpdate: (SQL)
|
||||
public static final int ERROR_INVALID_FOR_EXECUTE = 0x2312; //not a valid sql for execute: (SQL)
|
||||
public static final int ERROR_PARAMETER_INDEX_OUT_RANGE = 0x2313; // parameter index out of range
|
||||
public static final int ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED = 0x2314; // connection already closed
|
||||
public static final int ERROR_DATABASE_NOT_SPECIFIED_OR_AVAILABLE = 0x230a; //Database not specified or available
|
||||
public static final int ERROR_INVALID_FOR_EXECUTE_UPDATE = 0x230b; //not a valid sql for executeUpdate: (SQL)
|
||||
public static final int ERROR_INVALID_FOR_EXECUTE = 0x230c; //not a valid sql for execute: (SQL)
|
||||
public static final int ERROR_PARAMETER_INDEX_OUT_RANGE = 0x230d; // parameter index out of range
|
||||
public static final int ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED = 0x230e; // connection already closed
|
||||
|
||||
public static final int ERROR_UNKNOWN = 0x2350; //unknown error
|
||||
|
||||
public static final int ERROR_SUBSCRIBE_FAILED = 0x2351; //failed to create subscription
|
||||
public static final int ERROR_UNSUPPORTED_ENCODING = 0x2352; //Unsupported encoding
|
||||
public static final int ERROR_SUBSCRIBE_FAILED = 0x2351; // failed to create subscription
|
||||
public static final int ERROR_UNSUPPORTED_ENCODING = 0x2352; // Unsupported encoding
|
||||
|
||||
public static final int ERROR_JNI_TDENGINE_ERROR = 0x2353;
|
||||
public static final int ERROR_JNI_CONNECTION_NULL = 0x2354; //invalid tdengine connection!
|
||||
public static final int ERROR_JNI_RESULT_SET_NULL = 0x2355;
|
||||
public static final int ERROR_JNI_NUM_OF_FIELDS_0 = 0x2356;
|
||||
public static final int ERROR_JNI_SQL_NULL = 0x2357;
|
||||
public static final int ERROR_JNI_FETCH_END = 0x2358;
|
||||
public static final int ERROR_JNI_OUT_OF_MEMORY = 0x2359;
|
||||
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_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
|
||||
public static final int ERROR_JNI_FETCH_END = 0x2358; // fetch to the end of resultSet
|
||||
public static final int ERROR_JNI_OUT_OF_MEMORY = 0x2359; // JNI alloc memory failed
|
||||
|
||||
private static final HashSet<Integer> errorNumbers;
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ public class TSDBJNIConnector {
|
|||
|
||||
this.taos = this.connectImp(host, port, dbName, user, password);
|
||||
if (this.taos == TSDBConstants.JNI_NULL_POINTER) {
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg(this.getErrMsg(0L)), "", this.getErrCode(0l));
|
||||
throw TSDBError.createSQLException(this.getErrCode(0l), this.getErrMsg(0L));
|
||||
// throw new SQLException(TSDBConstants.WrapErrMsg(, "", );
|
||||
}
|
||||
// invoke connectImp only here
|
||||
taosInfo.conn_open_increment();
|
||||
|
@ -187,7 +188,6 @@ public class TSDBJNIConnector {
|
|||
// public long getResultSet() {
|
||||
// return taosResultSetPointer;
|
||||
// }
|
||||
|
||||
private native long getResultSetImp(long connection, long pSql);
|
||||
|
||||
public boolean isUpdateQuery(long pSql) {
|
||||
|
@ -227,7 +227,6 @@ public class TSDBJNIConnector {
|
|||
// }
|
||||
// return resCode;
|
||||
// }
|
||||
|
||||
private native int freeResultSetImp(long connection, long result);
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<dependency>
|
||||
<groupId>com.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
<version>2.0.18</version>
|
||||
<version>2.0.14</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
Loading…
Reference in New Issue