提交 faa7a555 编写于 作者: Z zyyang

change

上级 cd05259c
......@@ -436,7 +436,7 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
@Override
public void setClientInfo(String name, String value) throws SQLClientInfoException {
if (isClosed)
throw TSDBError.createSQLClientInfoException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
throw (SQLClientInfoException) TSDBError.createSQLException(TSDBErrorNumbers.ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED);
if (clientInfoProps == null)
clientInfoProps = new Properties();
......@@ -446,7 +446,8 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
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(); ) {
String name = (String) enumer.nextElement();
......@@ -457,7 +458,7 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
@Override
public String getClientInfo(String name) throws SQLException {
if (isClosed)
throw TSDBError.createSQLClientInfoException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
return clientInfoProps.getProperty(name);
}
......@@ -465,7 +466,7 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
@Override
public Properties getClientInfo() throws SQLException {
if (isClosed)
throw TSDBError.createSQLClientInfoException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
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, "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");
......@@ -48,24 +49,24 @@ public class TSDBError {
}
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))
message = TSDBErrorMap.get(errorNumber);
else
message = TSDBErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
}
// throw SQLFeatureNotSupportedException
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)
// 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
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 = 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_UNKNOWN = 0x2350; //unknown error
......@@ -47,6 +48,7 @@ public class TSDBErrorNumbers {
errorNumbers.add(ERROR_INVALID_FOR_EXECUTE_UPDATE);
errorNumbers.add(ERROR_INVALID_FOR_EXECUTE);
errorNumbers.add(ERROR_PARAMETER_INDEX_OUT_RANGE);
errorNumbers.add(ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED);
/*****************************************************/
errorNumbers.add(ERROR_SUBSCRIBE_FAILED);
......
......@@ -21,9 +21,6 @@ import java.sql.SQLException;
public class TSDBStatement extends AbstractStatement {
private TSDBJNIConnector connector;
/**
* To store batched commands
*/
/**
* Status of current statement
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册