change
This commit is contained in:
parent
cd05259c78
commit
faa7a55598
|
@ -436,7 +436,7 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
|
||||||
@Override
|
@Override
|
||||||
public void setClientInfo(String name, String value) throws SQLClientInfoException {
|
public void setClientInfo(String name, String value) throws SQLClientInfoException {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
throw TSDBError.createSQLClientInfoException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
throw (SQLClientInfoException) TSDBError.createSQLException(TSDBErrorNumbers.ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED);
|
||||||
|
|
||||||
if (clientInfoProps == null)
|
if (clientInfoProps == null)
|
||||||
clientInfoProps = new Properties();
|
clientInfoProps = new Properties();
|
||||||
|
@ -446,7 +446,8 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
|
||||||
@Override
|
@Override
|
||||||
public void setClientInfo(Properties properties) throws SQLClientInfoException {
|
public void setClientInfo(Properties properties) throws SQLClientInfoException {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
throw TSDBError.createSQLClientInfoException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
throw (SQLClientInfoException) TSDBError.createSQLException(TSDBErrorNumbers.ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED);
|
||||||
|
|
||||||
|
|
||||||
for (Enumeration<Object> enumer = properties.keys(); enumer.hasMoreElements(); ) {
|
for (Enumeration<Object> enumer = properties.keys(); enumer.hasMoreElements(); ) {
|
||||||
String name = (String) enumer.nextElement();
|
String name = (String) enumer.nextElement();
|
||||||
|
@ -457,7 +458,7 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
|
||||||
@Override
|
@Override
|
||||||
public String getClientInfo(String name) throws SQLException {
|
public String getClientInfo(String name) throws SQLException {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
throw TSDBError.createSQLClientInfoException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||||
|
|
||||||
return clientInfoProps.getProperty(name);
|
return clientInfoProps.getProperty(name);
|
||||||
}
|
}
|
||||||
|
@ -465,7 +466,7 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
|
||||||
@Override
|
@Override
|
||||||
public Properties getClientInfo() throws SQLException {
|
public Properties getClientInfo() throws SQLException {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
throw TSDBError.createSQLClientInfoException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||||
|
|
||||||
return clientInfoProps;
|
return clientInfoProps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ public class TSDBError {
|
||||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_UPDATE, "not a valid sql for executeUpdate: (?)");
|
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_UPDATE, "not a valid sql for executeUpdate: (?)");
|
||||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE, "not a valid sql for execute: (?)");
|
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_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_UNKNOWN, "unknown error");
|
||||||
|
@ -48,24 +49,24 @@ public class TSDBError {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SQLException createSQLException(int errorNumber, String message) {
|
public static SQLException createSQLException(int errorNumber, String message) {
|
||||||
if (message == null || message.isEmpty()) {
|
if (message == null || message.isEmpty() || message.replaceAll("\\s", "").isEmpty()) {
|
||||||
if (TSDBErrorNumbers.contains(errorNumber))
|
if (TSDBErrorNumbers.contains(errorNumber))
|
||||||
message = TSDBErrorMap.get(errorNumber);
|
message = TSDBErrorMap.get(errorNumber);
|
||||||
else
|
else
|
||||||
message = TSDBErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
|
message = TSDBErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
// throw SQLFeatureNotSupportedException
|
||||||
if (errorNumber == TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD)
|
if (errorNumber == TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD)
|
||||||
return new SQLFeatureNotSupportedException(message);
|
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)
|
if (errorNumber < TSDBErrorNumbers.ERROR_UNKNOWN)
|
||||||
// JDBC exception's error number is less than 0x2350
|
// JDBC exception's error number is less than 0x2350
|
||||||
return new SQLException("ERROR (" + Integer.toHexString(errorNumber) + "): " + message);
|
return new SQLException("ERROR (" + Integer.toHexString(errorNumber) + "): " + message, "", errorNumber);
|
||||||
// JNI exception's error number is large than 0x2350
|
// JNI exception's error number is large than 0x2350
|
||||||
return new SQLException("TDengine ERROR (" + Integer.toHexString(errorNumber) + "): " + message);
|
return new SQLException("TDengine ERROR (" + Integer.toHexString(errorNumber) + "): " + message, "", errorNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SQLClientInfoException createSQLClientInfoException(int errorNumber) {
|
|
||||||
return new SQLClientInfoException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class TSDBErrorNumbers {
|
||||||
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_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_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_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_UNKNOWN = 0x2350; //unknown error
|
public static final int ERROR_UNKNOWN = 0x2350; //unknown error
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ public class TSDBErrorNumbers {
|
||||||
errorNumbers.add(ERROR_INVALID_FOR_EXECUTE_UPDATE);
|
errorNumbers.add(ERROR_INVALID_FOR_EXECUTE_UPDATE);
|
||||||
errorNumbers.add(ERROR_INVALID_FOR_EXECUTE);
|
errorNumbers.add(ERROR_INVALID_FOR_EXECUTE);
|
||||||
errorNumbers.add(ERROR_PARAMETER_INDEX_OUT_RANGE);
|
errorNumbers.add(ERROR_PARAMETER_INDEX_OUT_RANGE);
|
||||||
|
errorNumbers.add(ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED);
|
||||||
|
|
||||||
/*****************************************************/
|
/*****************************************************/
|
||||||
errorNumbers.add(ERROR_SUBSCRIBE_FAILED);
|
errorNumbers.add(ERROR_SUBSCRIBE_FAILED);
|
||||||
|
|
|
@ -21,9 +21,6 @@ import java.sql.SQLException;
|
||||||
public class TSDBStatement extends AbstractStatement {
|
public class TSDBStatement extends AbstractStatement {
|
||||||
|
|
||||||
private TSDBJNIConnector connector;
|
private TSDBJNIConnector connector;
|
||||||
/**
|
|
||||||
* To store batched commands
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Status of current statement
|
* Status of current statement
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue