Merge branch 'develop' into xiaoping/add_test_case

This commit is contained in:
Ping Xiao 2021-02-07 14:41:47 +08:00
commit 42d5896ba1
46 changed files with 3529 additions and 3104 deletions

17
Jenkinsfile vendored
View File

@ -80,25 +80,28 @@ pipeline {
} }
steps { steps {
sh''' sh'''
cd ${WORKSPACE} cp -r ${WORKSPACE} ${WORKSPACE}.tes
cd ${WORKSPACE}.tes
git checkout develop git checkout develop
git pull git pull
git fetch origin +refs/pull/${CHANGE_ID}/merge git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD git checkout -qf FETCH_HEAD
''' '''
script{ script{
skipstage=sh(script:"git --no-pager diff --name-only FETCH_HEAD develop|grep -v -E '.*md|//src//connector|Jenkinsfile|test-all.sh' || echo 1 ",returnStdout:true) skipstage=sh(script:"git --no-pager diff --name-only FETCH_HEAD develop|grep -v -E '.*md|//src//connector|Jenkinsfile|test-all.sh' || echo 0 ",returnStdout:true)
} }
sh'''
rm -rf ${WORKSPACE}.tes
'''
} }
} }
stage('Parallel test stage') { stage('Parallel test stage') {
//only build pr //only build pr
when { when {
changeRequest() changeRequest()
expression { expression {
skipstage != 1 skipstage != 0
} }
} }
parallel { parallel {
@ -161,6 +164,7 @@ pipeline {
stage('test_crash_gen_s3') { stage('test_crash_gen_s3') {
agent{label "b2"} agent{label "b2"}
steps { steps {
pre_test() pre_test()
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
@ -172,6 +176,8 @@ pipeline {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh ''' sh '''
cd ${WKC}/tests/pytest cd ${WKC}/tests/pytest
rm -rf /var/lib/taos/*
rm -rf /var/log/taos/*
./handle_crash_gen_val_log.sh ./handle_crash_gen_val_log.sh
''' '''
} }
@ -183,6 +189,7 @@ pipeline {
date date
''' '''
} }
} }
} }
@ -216,6 +223,8 @@ pipeline {
date date
cd ${WKC}/tests cd ${WKC}/tests
./test-all.sh b4fq ./test-all.sh b4fq
cd ${WKC}/tests
./test-all.sh p4
date''' date'''
} }
} }

View File

@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver) #INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .) #INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED) IF (TD_MVN_INSTALLED)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.18-dist.jar DESTINATION connector/jdbc) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.19-dist.jar DESTINATION connector/jdbc)
ENDIF () ENDIF ()
ELSEIF (TD_DARWIN) ELSEIF (TD_DARWIN)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")

View File

@ -233,6 +233,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
// We extract the lock to tscBuildHeartBeatMsg function. // We extract the lock to tscBuildHeartBeatMsg function.
int64_t now = taosGetTimestampMs();
SSqlObj *pSql = pObj->sqlList; SSqlObj *pSql = pObj->sqlList;
while (pSql) { while (pSql) {
/* /*
@ -247,7 +248,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
tstrncpy(pQdesc->sql, pSql->sqlstr, sizeof(pQdesc->sql)); tstrncpy(pQdesc->sql, pSql->sqlstr, sizeof(pQdesc->sql));
pQdesc->stime = htobe64(pSql->stime); pQdesc->stime = htobe64(pSql->stime);
pQdesc->queryId = htonl(pSql->queryId); pQdesc->queryId = htonl(pSql->queryId);
pQdesc->useconds = htobe64(pSql->res.useconds); //pQdesc->useconds = htobe64(pSql->res.useconds);
pQdesc->useconds = htobe64(now - pSql->stime);
pQdesc->qHandle = htobe64(pSql->res.qhandle); pQdesc->qHandle = htobe64(pSql->res.qhandle);
pHeartbeat->numOfQueries++; pHeartbeat->numOfQueries++;

View File

@ -64,7 +64,7 @@ void tscReleaseRpc(void *param) {
return; return;
} }
pthread_mutex_lock(&rpcObjMutex); pthread_mutex_lock(&rpcObjMutex);
taosCacheRelease(tscRpcCache, (void *)&param, true); taosCacheRelease(tscRpcCache, (void *)&param, false);
pthread_mutex_unlock(&rpcObjMutex); pthread_mutex_unlock(&rpcObjMutex);
} }
@ -101,7 +101,7 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
tscError("failed to init connection to TDengine"); tscError("failed to init connection to TDengine");
return -1; return -1;
} }
pRpcObj = taosCachePut(tscRpcCache, rpcObj.key, strlen(rpcObj.key), &rpcObj, sizeof(rpcObj), 1000*10); pRpcObj = taosCachePut(tscRpcCache, rpcObj.key, strlen(rpcObj.key), &rpcObj, sizeof(rpcObj), 1000*5);
if (pRpcObj == NULL) { if (pRpcObj == NULL) {
rpcClose(rpcObj.pDnodeConn); rpcClose(rpcObj.pDnodeConn);
pthread_mutex_unlock(&rpcObjMutex); pthread_mutex_unlock(&rpcObjMutex);
@ -154,6 +154,7 @@ void taos_init_imp(void) {
if (tscNumOfThreads < 2) { if (tscNumOfThreads < 2) {
tscNumOfThreads = 2; tscNumOfThreads = 2;
} }
taosTmrThreads = tscNumOfThreads;
tscQhandle = taosInitScheduler(queueSize, tscNumOfThreads, "tsc"); tscQhandle = taosInitScheduler(queueSize, tscNumOfThreads, "tsc");
if (NULL == tscQhandle) { if (NULL == tscQhandle) {

View File

@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME} ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
POST_BUILD POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.18-dist.jar ${LIBRARY_OUTPUT_PATH} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.19-dist.jar ${LIBRARY_OUTPUT_PATH}
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMENT "build jdbc driver") COMMENT "build jdbc driver")
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME}) ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})

View File

@ -5,7 +5,7 @@
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.18</version> <version>2.0.19</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>JDBCDriver</name> <name>JDBCDriver</name>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.18</version> <version>2.0.19</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>JDBCDriver</name> <name>JDBCDriver</name>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url> <url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
@ -81,8 +81,6 @@
<artifactId>commons-dbcp2</artifactId> <artifactId>commons-dbcp2</artifactId>
<version>2.7.0</version> <version>2.7.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
@ -132,6 +130,7 @@
<exclude>**/AppMemoryLeakTest.java</exclude> <exclude>**/AppMemoryLeakTest.java</exclude>
<exclude>**/TaosInfoMonitorTest.java</exclude> <exclude>**/TaosInfoMonitorTest.java</exclude>
<exclude>**/FailOverTest.java</exclude> <exclude>**/FailOverTest.java</exclude>
<exclude>**/InvalidResultSetPointerTest.java</exclude>
</excludes> </excludes>
<testFailureIgnore>true</testFailureIgnore> <testFailureIgnore>true</testFailureIgnore>
</configuration> </configuration>

View File

@ -8,7 +8,7 @@ import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
public abstract class AbstractTaosDriver implements Driver { public abstract class AbstractDriver implements Driver {
private static final String TAOS_CFG_FILENAME = "taos.cfg"; private static final String TAOS_CFG_FILENAME = "taos.cfg";

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,249 @@
package com.taosdata.jdbc;
import java.sql.*;
public abstract class AbstractStatement extends WrapperImpl implements Statement {
private volatile boolean closeOnCompletion;
private int fetchSize;
@Override
public abstract ResultSet executeQuery(String sql) throws SQLException;
@Override
public abstract int executeUpdate(String sql) throws SQLException;
@Override
public abstract void close() throws SQLException;
@Override
public int getMaxFieldSize() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return TSDBConstants.maxFieldSize;
}
@Override
public void setMaxFieldSize(int max) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
if (max < 0)
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
// nothing to do
}
@Override
public int getMaxRows() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return 0;
}
@Override
public void setMaxRows(int max) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
if (max < 0)
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
// nothing to do
}
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
}
@Override
public int getQueryTimeout() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return 0;
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
if (seconds < 0)
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
}
@Override
public void cancel() throws SQLException {
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
}
@Override
public SQLWarning getWarnings() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return null;
}
@Override
public void clearWarnings() throws SQLException {
// nothing to do
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
}
@Override
public void setCursorName(String name) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
}
@Override
public abstract boolean execute(String sql) throws SQLException;
@Override
public abstract ResultSet getResultSet() throws SQLException;
@Override
public abstract int getUpdateCount() throws SQLException;
@Override
public boolean getMoreResults() throws SQLException {
return getMoreResults(CLOSE_CURRENT_RESULT);
}
@Override
public void setFetchDirection(int direction) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
//nothing to do
}
@Override
public int getFetchDirection() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return ResultSet.FETCH_FORWARD;
}
@Override
public void setFetchSize(int rows) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
if (rows < 0)
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
//nothing to do
this.fetchSize = rows;
}
@Override
public int getFetchSize() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return this.fetchSize;
}
@Override
public int getResultSetConcurrency() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return ResultSet.CONCUR_READ_ONLY;
}
@Override
public int getResultSetType() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return ResultSet.TYPE_FORWARD_ONLY;
}
@Override
public abstract void addBatch(String sql) throws SQLException;
@Override
public abstract void clearBatch() throws SQLException;
@Override
public abstract int[] executeBatch() throws SQLException;
@Override
public abstract Connection getConnection() throws SQLException;
@Override
public boolean getMoreResults(int current) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return false;
}
@Override
public ResultSet getGeneratedKeys() throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
}
@Override
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
}
@Override
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
}
@Override
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
}
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
}
@Override
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
}
@Override
public boolean execute(String sql, String[] columnNames) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
}
@Override
public int getResultSetHoldability() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return ResultSet.HOLD_CURSORS_OVER_COMMIT;
}
@Override
public abstract boolean isClosed() throws SQLException;
@Override
public void setPoolable(boolean poolable) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
//nothing to do
}
@Override
public boolean isPoolable() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return false;
}
@Override
public void closeOnCompletion() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
this.closeOnCompletion = true;
}
@Override
public boolean isCloseOnCompletion() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
return this.closeOnCompletion;
}
}

View File

@ -160,12 +160,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public Date getDate(int columnIndex) throws SQLException { public Date getDate(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public Time getTime(int columnIndex) throws SQLException { public Time getTime(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -176,17 +176,17 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public InputStream getAsciiStream(int columnIndex) throws SQLException { public InputStream getAsciiStream(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public InputStream getUnicodeStream(int columnIndex) throws SQLException { public InputStream getUnicodeStream(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public InputStream getBinaryStream(int columnIndex) throws SQLException { public InputStream getBinaryStream(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -256,22 +256,22 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public InputStream getAsciiStream(String columnLabel) throws SQLException { public InputStream getAsciiStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public InputStream getUnicodeStream(String columnLabel) throws SQLException { public InputStream getUnicodeStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public InputStream getBinaryStream(String columnLabel) throws SQLException { public InputStream getBinaryStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public SQLWarning getWarnings() throws SQLException { public SQLWarning getWarnings() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -281,7 +281,7 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public String getCursorName() throws SQLException { public String getCursorName() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -313,12 +313,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public Reader getCharacterStream(int columnIndex) throws SQLException { public Reader getCharacterStream(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public Reader getCharacterStream(String columnLabel) throws SQLException { public Reader getCharacterStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -353,22 +353,22 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public void beforeFirst() throws SQLException { public void beforeFirst() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void afterLast() throws SQLException { public void afterLast() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public boolean first() throws SQLException { public boolean first() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public boolean last() throws SQLException { public boolean last() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -383,17 +383,17 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public boolean absolute(int row) throws SQLException { public boolean absolute(int row) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public boolean relative(int rows) throws SQLException { public boolean relative(int rows) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public boolean previous() throws SQLException { public boolean previous() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -443,227 +443,227 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public void updateNull(int columnIndex) throws SQLException { public void updateNull(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateBoolean(int columnIndex, boolean x) throws SQLException { public void updateBoolean(int columnIndex, boolean x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateByte(int columnIndex, byte x) throws SQLException { public void updateByte(int columnIndex, byte x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateShort(int columnIndex, short x) throws SQLException { public void updateShort(int columnIndex, short x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateInt(int columnIndex, int x) throws SQLException { public void updateInt(int columnIndex, int x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateLong(int columnIndex, long x) throws SQLException { public void updateLong(int columnIndex, long x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateFloat(int columnIndex, float x) throws SQLException { public void updateFloat(int columnIndex, float x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateDouble(int columnIndex, double x) throws SQLException { public void updateDouble(int columnIndex, double x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateString(int columnIndex, String x) throws SQLException { public void updateString(int columnIndex, String x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateBytes(int columnIndex, byte[] x) throws SQLException { public void updateBytes(int columnIndex, byte[] x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateDate(int columnIndex, Date x) throws SQLException { public void updateDate(int columnIndex, Date x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateTime(int columnIndex, Time x) throws SQLException { public void updateTime(int columnIndex, Time x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateObject(int columnIndex, Object x) throws SQLException { public void updateObject(int columnIndex, Object x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateNull(String columnLabel) throws SQLException { public void updateNull(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateBoolean(String columnLabel, boolean x) throws SQLException { public void updateBoolean(String columnLabel, boolean x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateByte(String columnLabel, byte x) throws SQLException { public void updateByte(String columnLabel, byte x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateShort(String columnLabel, short x) throws SQLException { public void updateShort(String columnLabel, short x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateInt(String columnLabel, int x) throws SQLException { public void updateInt(String columnLabel, int x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateLong(String columnLabel, long x) throws SQLException { public void updateLong(String columnLabel, long x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateFloat(String columnLabel, float x) throws SQLException { public void updateFloat(String columnLabel, float x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateDouble(String columnLabel, double x) throws SQLException { public void updateDouble(String columnLabel, double x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateString(String columnLabel, String x) throws SQLException { public void updateString(String columnLabel, String x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateBytes(String columnLabel, byte[] x) throws SQLException { public void updateBytes(String columnLabel, byte[] x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateDate(String columnLabel, Date x) throws SQLException { public void updateDate(String columnLabel, Date x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateTime(String columnLabel, Time x) throws SQLException { public void updateTime(String columnLabel, Time x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateObject(String columnLabel, Object x) throws SQLException { public void updateObject(String columnLabel, Object x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void insertRow() throws SQLException { public void insertRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void updateRow() throws SQLException { public void updateRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void deleteRow() throws SQLException { public void deleteRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void refreshRow() throws SQLException { public void refreshRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void cancelRowUpdates() throws SQLException { public void cancelRowUpdates() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void moveToInsertRow() throws SQLException { public void moveToInsertRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void moveToCurrentRow() throws SQLException { public void moveToCurrentRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -673,12 +673,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException { public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public Ref getRef(int columnIndex) throws SQLException { public Ref getRef(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -1043,12 +1043,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException { public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException { public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override

View File

@ -20,7 +20,7 @@ import java.util.Map;
public abstract class TSDBConstants { public abstract class TSDBConstants {
public static final String STATEMENT_CLOSED = "statement is closed"; public static final String STATEMENT_CLOSED = "statement is closed";
public static final String UNSUPPORT_METHOD_EXCEPTIONZ_MSG = "this operation is NOT supported currently!"; public static final String UNSUPPORTED_METHOD_EXCEPTION_MSG = "this operation is NOT supported currently!";
public static final String INVALID_VARIABLES = "invalid variables"; public static final String INVALID_VARIABLES = "invalid variables";
public static final String RESULT_SET_IS_CLOSED = "resultSet is closed"; public static final String RESULT_SET_IS_CLOSED = "resultSet is closed";
@ -36,6 +36,7 @@ public abstract class TSDBConstants {
public static final int JNI_NUM_OF_FIELDS_0 = -4; public static final int JNI_NUM_OF_FIELDS_0 = -4;
public static final int JNI_SQL_NULL = -5; public static final int JNI_SQL_NULL = -5;
public static final int JNI_FETCH_END = -6; public static final int JNI_FETCH_END = -6;
public static final int JNI_OUT_OF_MEMORY = -7;
public static final int TSDB_DATA_TYPE_NULL = 0; public static final int TSDB_DATA_TYPE_NULL = 0;
public static final int TSDB_DATA_TYPE_BOOL = 1; public static final int TSDB_DATA_TYPE_BOOL = 1;

View File

@ -37,7 +37,7 @@ import java.util.logging.Logger;
* register it with the DriverManager. This means that a user can load and * register it with the DriverManager. This means that a user can load and
* register a driver by doing Class.forName("foo.bah.Driver") * register a driver by doing Class.forName("foo.bah.Driver")
*/ */
public class TSDBDriver extends AbstractTaosDriver { public class TSDBDriver extends AbstractDriver {
@Deprecated @Deprecated
private static final String URL_PREFIX1 = "jdbc:TSDB://"; private static final String URL_PREFIX1 = "jdbc:TSDB://";

View File

@ -1,6 +1,7 @@
package com.taosdata.jdbc; package com.taosdata.jdbc;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -13,8 +14,23 @@ public class TSDBError {
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_VARIABLE, "invalid variables"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_VARIABLE, "invalid variables");
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED, "statement is closed"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED, "statement is closed");
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED, "resultSet is closed"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED, "resultSet is closed");
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_BATCH_IS_EMPTY, "Batch is empty!");
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY, "Can not issue data manipulation statements with executeQuery()");
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEUPDATE, "Can not issue SELECT via executeUpdate()");
/**************************************************/
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown error");
/**************************************************/ /**************************************************/
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_SUBSCRIBE_FAILED, "failed to create subscription"); 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!");
} }
public static String wrapErrMsg(String msg) { public static String wrapErrMsg(String msg) {
@ -22,10 +38,24 @@ public class TSDBError {
} }
public static SQLException createSQLException(int errorNumber) { public static SQLException createSQLException(int errorNumber) {
// JDBC exception code is less than 0x2350 return createSQLException(errorNumber, null);
if (errorNumber <= 0x2350) }
return new SQLException(TSDBErrorMap.get(errorNumber));
// JNI exception code is public static SQLException createSQLException(int errorNumber, String message) {
return new SQLException(wrapErrMsg(TSDBErrorMap.get(errorNumber))); if (message == null || message.isEmpty()) {
if (TSDBErrorNumbers.contains(errorNumber))
message = TSDBErrorMap.get(errorNumber);
else
message = TSDBErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
}
if (errorNumber == TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD)
return new SQLFeatureNotSupportedException(message);
if (errorNumber < TSDBErrorNumbers.ERROR_UNKNOWN)
// JDBC exception's error number is less than 0x2350
return new SQLException("ERROR (" + Integer.toHexString(errorNumber) + "): " + message);
// JNI exception's error number is large than 0x2350
return new SQLException("TDengine ERROR (" + Integer.toHexString(errorNumber) + "): " + message);
} }
} }

View File

@ -1,5 +1,7 @@
package com.taosdata.jdbc; package com.taosdata.jdbc;
import java.util.HashSet;
public class TSDBErrorNumbers { public class TSDBErrorNumbers {
public static final int ERROR_CONNECTION_CLOSED = 0x2301; // connection already closed public static final int ERROR_CONNECTION_CLOSED = 0x2301; // connection already closed
@ -7,9 +9,52 @@ public class TSDBErrorNumbers {
public static final int ERROR_INVALID_VARIABLE = 0x2303; //invalid variables public static final int ERROR_INVALID_VARIABLE = 0x2303; //invalid variables
public static final int ERROR_STATEMENT_CLOSED = 0x2304; //statement already closed public static final int ERROR_STATEMENT_CLOSED = 0x2304; //statement already closed
public static final int ERROR_RESULTSET_CLOSED = 0x2305; //resultSet is closed public static final int ERROR_RESULTSET_CLOSED = 0x2305; //resultSet is closed
public static final int ERROR_BATCH_IS_EMPTY = 0x2306; //Batch is empty!
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_SUBSCRIBE_FAILED = 0x2350; //failed to create subscription 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_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;
private static final HashSet<Integer> errorNumbers;
static {
errorNumbers = new HashSet();
errorNumbers.add(ERROR_CONNECTION_CLOSED);
errorNumbers.add(ERROR_UNSUPPORTED_METHOD);
errorNumbers.add(ERROR_INVALID_VARIABLE);
errorNumbers.add(ERROR_STATEMENT_CLOSED);
errorNumbers.add(ERROR_RESULTSET_CLOSED);
errorNumbers.add(ERROR_INVALID_WITH_EXECUTEQUERY);
errorNumbers.add(ERROR_INVALID_WITH_EXECUTEUPDATE);
/*****************************************************/
errorNumbers.add(ERROR_SUBSCRIBE_FAILED);
errorNumbers.add(ERROR_UNSUPPORTED_ENCODING);
errorNumbers.add(ERROR_JNI_TDENGINE_ERROR);
errorNumbers.add(ERROR_JNI_CONNECTION_NULL);
errorNumbers.add(ERROR_JNI_RESULT_SET_NULL);
errorNumbers.add(ERROR_JNI_NUM_OF_FIELDS_0);
errorNumbers.add(ERROR_JNI_SQL_NULL);
errorNumbers.add(ERROR_JNI_FETCH_END);
errorNumbers.add(ERROR_JNI_OUT_OF_MEMORY);
}
private TSDBErrorNumbers() { private TSDBErrorNumbers() {
} }
public static boolean contains(int errorNumber) {
return errorNumbers.contains(errorNumber);
}
} }

View File

@ -38,7 +38,7 @@ public class TSDBJNIConnector {
/** /**
* Result set pointer for the current connection * Result set pointer for the current connection
*/ */
private long taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER; // private long taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
/** /**
* result set status in current connection * result set status in current connection
@ -119,9 +119,9 @@ public class TSDBJNIConnector {
public long executeQuery(String sql) throws SQLException { public long executeQuery(String sql) throws SQLException {
// close previous result set if the user forgets to invoke the // close previous result set if the user forgets to invoke the
// free method to close previous result set. // free method to close previous result set.
if (!this.isResultsetClosed) { // if (!this.isResultsetClosed) {
freeResultSet(taosResultSetPointer); // freeResultSet(taosResultSetPointer);
} // }
Long pSql = 0l; Long pSql = 0l;
try { try {
@ -130,21 +130,32 @@ public class TSDBJNIConnector {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
this.freeResultSetImp(this.taos, pSql); this.freeResultSetImp(this.taos, pSql);
throw new SQLException(TSDBConstants.WrapErrMsg("Unsupported encoding")); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING);
}
if (pSql == TSDBConstants.JNI_CONNECTION_NULL) {
this.freeResultSetImp(this.taos, pSql);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
}
if (pSql == TSDBConstants.JNI_SQL_NULL) {
this.freeResultSetImp(this.taos, pSql);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_SQL_NULL);
}
if (pSql == TSDBConstants.JNI_OUT_OF_MEMORY) {
this.freeResultSetImp(this.taos, pSql);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY);
} }
int code = this.getErrCode(pSql); int code = this.getErrCode(pSql);
if (code != 0) { if (code != TSDBConstants.JNI_SUCCESS) {
affectedRows = -1; affectedRows = -1;
String msg = this.getErrMsg(pSql); String msg = this.getErrMsg(pSql);
this.freeResultSetImp(this.taos, pSql); this.freeResultSetImp(this.taos, pSql);
throw new SQLException(TSDBConstants.WrapErrMsg(msg), "", code); throw TSDBError.createSQLException(code, msg);
} }
// Try retrieving result set for the executed SQL using the current connection pointer. // Try retrieving result set for the executed SQL using the current connection pointer.
taosResultSetPointer = this.getResultSetImp(this.taos, pSql); pSql = this.getResultSetImp(this.taos, pSql);
isResultsetClosed = (taosResultSetPointer == TSDBConstants.JNI_NULL_POINTER); isResultsetClosed = (pSql == TSDBConstants.JNI_NULL_POINTER);
return pSql; return pSql;
} }
@ -173,9 +184,9 @@ public class TSDBJNIConnector {
* Get resultset pointer * Get resultset pointer
* Each connection should have a single open result set at a time * Each connection should have a single open result set at a time
*/ */
public long getResultSet() { // public long getResultSet() {
return taosResultSetPointer; // return taosResultSetPointer;
} // }
private native long getResultSetImp(long connection, long pSql); private native long getResultSetImp(long connection, long pSql);
@ -188,16 +199,16 @@ public class TSDBJNIConnector {
/** /**
* Free resultset operation from C to release resultset pointer by JNI * Free resultset operation from C to release resultset pointer by JNI
*/ */
public int freeResultSet(long result) { public int freeResultSet(long pSql) {
int res = TSDBConstants.JNI_SUCCESS; int res = TSDBConstants.JNI_SUCCESS;
if (result != taosResultSetPointer && taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) { // if (result != taosResultSetPointer && taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
throw new RuntimeException("Invalid result set pointer"); // throw new RuntimeException("Invalid result set pointer");
} // }
if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) { // if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
res = this.freeResultSetImp(this.taos, result); res = this.freeResultSetImp(this.taos, pSql);
taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER; // taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
} // }
isResultsetClosed = true; isResultsetClosed = true;
return res; return res;
@ -207,15 +218,15 @@ public class TSDBJNIConnector {
* Close the open result set which is associated to the current connection. If the result set is already * Close the open result set which is associated to the current connection. If the result set is already
* closed, return 0 for success. * closed, return 0 for success.
*/ */
public int freeResultSet() { // public int freeResultSet() {
int resCode = TSDBConstants.JNI_SUCCESS; // int resCode = TSDBConstants.JNI_SUCCESS;
if (!isResultsetClosed) { // if (!isResultsetClosed) {
resCode = this.freeResultSetImp(this.taos, this.taosResultSetPointer); // resCode = this.freeResultSetImp(this.taos, this.taosResultSetPointer);
taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER; // taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
isResultsetClosed = true; // isResultsetClosed = true;
} // }
return resCode; // return resCode;
} // }
private native int freeResultSetImp(long connection, long result); private native int freeResultSetImp(long connection, long result);

View File

@ -264,17 +264,17 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
@Override @Override
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException { public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -284,7 +284,7 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
@Override @Override
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -321,156 +321,156 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
@Override @Override
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setRef(int parameterIndex, Ref x) throws SQLException { public void setRef(int parameterIndex, Ref x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setBlob(int parameterIndex, Blob x) throws SQLException { public void setBlob(int parameterIndex, Blob x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setClob(int parameterIndex, Clob x) throws SQLException { public void setClob(int parameterIndex, Clob x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setArray(int parameterIndex, Array x) throws SQLException { public void setArray(int parameterIndex, Array x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public ResultSetMetaData getMetaData() throws SQLException { public ResultSetMetaData getMetaData() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setURL(int parameterIndex, URL x) throws SQLException { public void setURL(int parameterIndex, URL x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public ParameterMetaData getParameterMetaData() throws SQLException { public ParameterMetaData getParameterMetaData() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setRowId(int parameterIndex, RowId x) throws SQLException { public void setRowId(int parameterIndex, RowId x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setNString(int parameterIndex, String value) throws SQLException { public void setNString(int parameterIndex, String value) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setNClob(int parameterIndex, NClob value) throws SQLException { public void setNClob(int parameterIndex, NClob value) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException { public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setClob(int parameterIndex, Reader reader) throws SQLException { public void setClob(int parameterIndex, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void setNClob(int parameterIndex, Reader reader) throws SQLException { public void setNClob(int parameterIndex, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
} }

View File

@ -14,36 +14,17 @@
*****************************************************************************/ *****************************************************************************/
package com.taosdata.jdbc; package com.taosdata.jdbc;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URL; import java.sql.*;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
public class TSDBResultSet implements ResultSet { public class TSDBResultSet extends AbstractResultSet implements ResultSet {
private TSDBJNIConnector jniConnector = null; private TSDBJNIConnector jniConnector;
private final TSDBStatement statement;
private long resultSetPointer = 0L; private long resultSetPointer = 0L;
private List<ColumnMetaData> columnMetaDataList = new ArrayList<ColumnMetaData>(); private List<ColumnMetaData> columnMetaDataList = new ArrayList<>();
private TSDBResultSetRowData rowData; private TSDBResultSetRowData rowData;
private TSDBResultSetBlockData blockData; private TSDBResultSetBlockData blockData;
@ -52,24 +33,6 @@ public class TSDBResultSet implements ResultSet {
private boolean lastWasNull = false; private boolean lastWasNull = false;
private final int COLUMN_INDEX_START_VALUE = 1; private final int COLUMN_INDEX_START_VALUE = 1;
private int rowIndex = 0;
public TSDBJNIConnector getJniConnector() {
return jniConnector;
}
public void setJniConnector(TSDBJNIConnector jniConnector) {
this.jniConnector = jniConnector;
}
public long getResultSetPointer() {
return resultSetPointer;
}
public void setResultSetPointer(long resultSetPointer) {
this.resultSetPointer = resultSetPointer;
}
public void setBatchFetch(boolean batchFetch) { public void setBatchFetch(boolean batchFetch) {
this.batchFetch = batchFetch; this.batchFetch = batchFetch;
} }
@ -78,10 +41,6 @@ public class TSDBResultSet implements ResultSet {
return this.batchFetch; return this.batchFetch;
} }
public List<ColumnMetaData> getColumnMetaDataList() {
return columnMetaDataList;
}
public void setColumnMetaDataList(List<ColumnMetaData> columnMetaDataList) { public void setColumnMetaDataList(List<ColumnMetaData> columnMetaDataList) {
this.columnMetaDataList = columnMetaDataList; this.columnMetaDataList = columnMetaDataList;
} }
@ -90,56 +49,25 @@ public class TSDBResultSet implements ResultSet {
return rowData; return rowData;
} }
public void setRowData(TSDBResultSetRowData rowData) { public TSDBResultSet(TSDBStatement statement, TSDBJNIConnector connector, long resultSetPointer) throws SQLException {
this.rowData = rowData; this.statement = statement;
}
public boolean isLastWasNull() {
return lastWasNull;
}
public void setLastWasNull(boolean lastWasNull) {
this.lastWasNull = lastWasNull;
}
public TSDBResultSet() {
}
public TSDBResultSet(TSDBJNIConnector connector, long resultSetPointer) throws SQLException {
this.jniConnector = connector; this.jniConnector = connector;
this.resultSetPointer = resultSetPointer; this.resultSetPointer = resultSetPointer;
int code = this.jniConnector.getSchemaMetaData(this.resultSetPointer, this.columnMetaDataList); int code = this.jniConnector.getSchemaMetaData(this.resultSetPointer, this.columnMetaDataList);
if (code == TSDBConstants.JNI_CONNECTION_NULL) { if (code == TSDBConstants.JNI_CONNECTION_NULL) {
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) { }
if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL)); throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL));
} else if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) { }
if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_NUM_OF_FIELDS_0)); throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_NUM_OF_FIELDS_0));
} }
this.rowData = new TSDBResultSetRowData(this.columnMetaDataList.size()); this.rowData = new TSDBResultSetRowData(this.columnMetaDataList.size());
this.blockData = new TSDBResultSetBlockData(this.columnMetaDataList, this.columnMetaDataList.size()); this.blockData = new TSDBResultSetBlockData(this.columnMetaDataList, this.columnMetaDataList.size());
} }
public <T> T unwrap(Class<T> iface) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.WrapErrMsg(TSDBConstants.RESULT_SET_IS_CLOSED));
try {
return iface.cast(this);
} catch (ClassCastException cce) {
throw new SQLException("Unable to unwrap to " + iface.toString());
}
}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.WrapErrMsg(TSDBConstants.RESULT_SET_IS_CLOSED));
return iface.isInstance(this);
}
public boolean next() throws SQLException { public boolean next() throws SQLException {
if (this.getBatchFetch()) { if (this.getBatchFetch()) {
if (this.blockData.forward()) { if (this.blockData.forward()) {
@ -273,7 +201,7 @@ public class TSDBResultSet implements ResultSet {
} }
public long getLong(int columnIndex) throws SQLException { public long getLong(int columnIndex) throws SQLException {
long res = 0l; long res = 0L;
int colIndex = getTrueColumnIndex(columnIndex); int colIndex = getTrueColumnIndex(columnIndex);
if (!this.getBatchFetch()) { if (!this.getBatchFetch()) {
@ -317,14 +245,6 @@ public class TSDBResultSet implements ResultSet {
} }
} }
/*
* (non-Javadoc)
*
* @see java.sql.ResultSet#getBigDecimal(int, int)
*
* @deprecated Use {@code getBigDecimal(int columnIndex)} or {@code
* getBigDecimal(String columnLabel)}
*/
@Deprecated @Deprecated
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
return new BigDecimal(getLong(columnIndex)); return new BigDecimal(getLong(columnIndex));
@ -334,16 +254,6 @@ public class TSDBResultSet implements ResultSet {
return getString(columnIndex).getBytes(); return getString(columnIndex).getBytes();
} }
public Date getDate(int columnIndex) throws SQLException {
int colIndex = getTrueColumnIndex(columnIndex);
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Time getTime(int columnIndex) throws SQLException {
int colIndex = getTrueColumnIndex(columnIndex);
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Timestamp getTimestamp(int columnIndex) throws SQLException { public Timestamp getTimestamp(int columnIndex) throws SQLException {
Timestamp res = null; Timestamp res = null;
int colIndex = getTrueColumnIndex(columnIndex); int colIndex = getTrueColumnIndex(columnIndex);
@ -359,112 +269,11 @@ public class TSDBResultSet implements ResultSet {
} }
} }
public InputStream getAsciiStream(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
/*
* (non-Javadoc)
*
* @see java.sql.ResultSet#getUnicodeStream(int)
*
* * @deprecated use <code>getCharacterStream</code> in place of
* <code>getUnicodeStream</code>
*/
@Deprecated
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public InputStream getBinaryStream(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public String getString(String columnLabel) throws SQLException {
return this.getString(this.findColumn(columnLabel));
}
public boolean getBoolean(String columnLabel) throws SQLException {
return this.getBoolean(this.findColumn(columnLabel));
}
public byte getByte(String columnLabel) throws SQLException {
return this.getByte(this.findColumn(columnLabel));
}
public short getShort(String columnLabel) throws SQLException {
return this.getShort(this.findColumn(columnLabel));
}
public int getInt(String columnLabel) throws SQLException {
return this.getInt(this.findColumn(columnLabel));
}
public long getLong(String columnLabel) throws SQLException {
return this.getLong(this.findColumn(columnLabel));
}
public float getFloat(String columnLabel) throws SQLException {
return this.getFloat(this.findColumn(columnLabel));
}
public double getDouble(String columnLabel) throws SQLException {
return this.getDouble(this.findColumn(columnLabel));
}
/*
* used by spark
*/
@Deprecated
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
return this.getBigDecimal(this.findColumn(columnLabel), scale);
}
public byte[] getBytes(String columnLabel) throws SQLException {
return this.getBytes(this.findColumn(columnLabel));
}
public Date getDate(String columnLabel) throws SQLException {
return this.getDate(this.findColumn(columnLabel));
}
public Time getTime(String columnLabel) throws SQLException {
return this.getTime(this.findColumn(columnLabel));
}
public Timestamp getTimestamp(String columnLabel) throws SQLException {
return this.getTimestamp(this.findColumn(columnLabel));
}
public InputStream getAsciiStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Deprecated
public InputStream getUnicodeStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public InputStream getBinaryStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public SQLWarning getWarnings() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void clearWarnings() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public String getCursorName() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public ResultSetMetaData getMetaData() throws SQLException { public ResultSetMetaData getMetaData() throws SQLException {
return new TSDBResultSetMetaData(this.columnMetaDataList); return new TSDBResultSetMetaData(this.columnMetaDataList);
} }
@Override
public Object getObject(int columnIndex) throws SQLException { public Object getObject(int columnIndex) throws SQLException {
int colIndex = getTrueColumnIndex(columnIndex); int colIndex = getTrueColumnIndex(columnIndex);
@ -476,32 +285,21 @@ public class TSDBResultSet implements ResultSet {
} }
} }
@Override
public Object getObject(String columnLabel) throws SQLException { public Object getObject(String columnLabel) throws SQLException {
return this.getObject(this.findColumn(columnLabel)); return this.getObject(this.findColumn(columnLabel));
} }
public int findColumn(String columnLabel) throws SQLException { public int findColumn(String columnLabel) throws SQLException {
Iterator<ColumnMetaData> colMetaDataIt = this.columnMetaDataList.iterator(); for (ColumnMetaData colMetaData : this.columnMetaDataList) {
while (colMetaDataIt.hasNext()) {
ColumnMetaData colMetaData = colMetaDataIt.next();
if (colMetaData.getColName() != null && colMetaData.getColName().equalsIgnoreCase(columnLabel)) { if (colMetaData.getColName() != null && colMetaData.getColName().equalsIgnoreCase(columnLabel)) {
return colMetaData.getColIndex() + 1; return colMetaData.getColIndex() + 1;
} }
} }
throw new SQLException(TSDBConstants.INVALID_VARIABLES); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
} }
public Reader getCharacterStream(int columnIndex) throws SQLException { @Override
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Reader getCharacterStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
/*
* used by spark
*/
public BigDecimal getBigDecimal(int columnIndex) throws SQLException { public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
int colIndex = getTrueColumnIndex(columnIndex); int colIndex = getTrueColumnIndex(columnIndex);
@ -513,403 +311,111 @@ public class TSDBResultSet implements ResultSet {
} }
} }
public BigDecimal getBigDecimal(String columnLabel) throws SQLException { @Override
return this.getBigDecimal(this.findColumn(columnLabel));
}
public boolean isBeforeFirst() throws SQLException { public boolean isBeforeFirst() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public boolean isAfterLast() throws SQLException { public boolean isAfterLast() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public boolean isFirst() throws SQLException { public boolean isFirst() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public boolean isLast() throws SQLException { public boolean isLast() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public void beforeFirst() throws SQLException { public void beforeFirst() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public void afterLast() throws SQLException { public void afterLast() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public boolean first() throws SQLException { public boolean first() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public boolean last() throws SQLException { public boolean last() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public int getRow() throws SQLException { public int getRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public boolean absolute(int row) throws SQLException { public boolean absolute(int row) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public boolean relative(int rows) throws SQLException { public boolean relative(int rows) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
} }
@Override
public boolean previous() throws SQLException { public boolean previous() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
} throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
public void setFetchDirection(int direction) throws SQLException { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getFetchDirection() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void setFetchSize(int rows) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getFetchSize() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getType() throws SQLException {
return ResultSet.TYPE_FORWARD_ONLY;
}
public int getConcurrency() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean rowUpdated() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean rowInserted() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean rowDeleted() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNull(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBoolean(int columnIndex, boolean x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateByte(int columnIndex, byte x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateShort(int columnIndex, short x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateInt(int columnIndex, int x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateLong(int columnIndex, long x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateFloat(int columnIndex, float x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateDouble(int columnIndex, double x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateString(int columnIndex, String x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBytes(int columnIndex, byte[] x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateDate(int columnIndex, Date x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateTime(int columnIndex, Time x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateObject(int columnIndex, Object x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNull(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBoolean(String columnLabel, boolean x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateByte(String columnLabel, byte x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateShort(String columnLabel, short x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateInt(String columnLabel, int x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateLong(String columnLabel, long x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateFloat(String columnLabel, float x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateDouble(String columnLabel, double x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateString(String columnLabel, String x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBytes(String columnLabel, byte[] x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateDate(String columnLabel, Date x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateTime(String columnLabel, Time x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateObject(String columnLabel, Object x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void insertRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void deleteRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void refreshRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void cancelRowUpdates() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void moveToInsertRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void moveToCurrentRow() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
} }
public Statement getStatement() throws SQLException { public Statement getStatement() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); if (isClosed())
} throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException { return this.statement;
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Ref getRef(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Blob getBlob(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Clob getClob(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Array getArray(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Ref getRef(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Blob getBlob(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Clob getClob(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Array getArray(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Date getDate(String columnLabel, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Time getTime(String columnLabel, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public URL getURL(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public URL getURL(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateRef(int columnIndex, Ref x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateRef(String columnLabel, Ref x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBlob(int columnIndex, Blob x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBlob(String columnLabel, Blob x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateClob(int columnIndex, Clob x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateClob(String columnLabel, Clob x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateArray(int columnIndex, Array x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateArray(String columnLabel, Array x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public RowId getRowId(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public RowId getRowId(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateRowId(int columnIndex, RowId x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateRowId(String columnLabel, RowId x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getHoldability() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
} }
public boolean isClosed() throws SQLException { public boolean isClosed() throws SQLException {
//TODO: check if need release resources
boolean isClosed = true; boolean isClosed = true;
if (jniConnector != null) { if (jniConnector != null) {
isClosed = jniConnector.isResultsetClosed(); isClosed = jniConnector.isResultsetClosed();
@ -917,183 +423,11 @@ public class TSDBResultSet implements ResultSet {
return isClosed; return isClosed;
} }
public void updateNString(int columnIndex, String nString) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNString(String columnLabel, String nString) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public NClob getNClob(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public NClob getNClob(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public SQLXML getSQLXML(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public SQLXML getSQLXML(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public String getNString(int columnIndex) throws SQLException { public String getNString(int columnIndex) throws SQLException {
int colIndex = getTrueColumnIndex(columnIndex); int colIndex = getTrueColumnIndex(columnIndex);
return (String) rowData.get(colIndex); return (String) rowData.get(colIndex);
} }
public String getNString(String columnLabel) throws SQLException {
return (String) this.getString(columnLabel);
}
public Reader getNCharacterStream(int columnIndex) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public Reader getNCharacterStream(String columnLabel) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateClob(int columnIndex, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateClob(String columnLabel, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNClob(int columnIndex, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void updateNClob(String columnLabel, Reader reader) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
private int getTrueColumnIndex(int columnIndex) throws SQLException { private int getTrueColumnIndex(int columnIndex) throws SQLException {
if (columnIndex < this.COLUMN_INDEX_START_VALUE) { if (columnIndex < this.COLUMN_INDEX_START_VALUE) {
throw new SQLException("Column Index out of range, " + columnIndex + " < " + this.COLUMN_INDEX_START_VALUE); throw new SQLException("Column Index out of range, " + columnIndex + " < " + this.COLUMN_INDEX_START_VALUE);
@ -1103,7 +437,6 @@ public class TSDBResultSet implements ResultSet {
if (columnIndex > numOfCols) { if (columnIndex > numOfCols) {
throw new SQLException("Column Index out of range, " + columnIndex + " > " + numOfCols); throw new SQLException("Column Index out of range, " + columnIndex + " > " + numOfCols);
} }
return columnIndex - 1; return columnIndex - 1;
} }
} }

View File

@ -29,11 +29,11 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
} }
public <T> T unwrap(Class<T> iface) throws SQLException { public <T> T unwrap(Class<T> iface) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
public boolean isWrapperFor(Class<?> iface) throws SQLException { public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
public int getColumnCount() throws SQLException { public int getColumnCount() throws SQLException {
@ -94,7 +94,7 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
} }
public String getSchemaName(int column) throws SQLException { public String getSchemaName(int column) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
public int getPrecision(int column) throws SQLException { public int getPrecision(int column) throws SQLException {
@ -125,11 +125,11 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
} }
public String getTableName(int column) throws SQLException { public String getTableName(int column) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
public String getCatalogName(int column) throws SQLException { public String getCatalogName(int column) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
public int getColumnType(int column) throws SQLException { public int getColumnType(int column) throws SQLException {
@ -173,7 +173,7 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
} }
public boolean isDefinitelyWritable(int column) throws SQLException { public boolean isDefinitelyWritable(int column) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
public String getColumnClassName(int column) throws SQLException { public String getColumnClassName(int column) throws SQLException {

View File

@ -1153,11 +1153,11 @@ public class TSDBResultSetWrapper implements ResultSet {
} }
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException { public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException { public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override

View File

@ -14,34 +14,24 @@
*****************************************************************************/ *****************************************************************************/
package com.taosdata.jdbc; package com.taosdata.jdbc;
import com.taosdata.jdbc.utils.TaosInfo;
import java.sql.*; import java.sql.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class TSDBStatement implements Statement { public class TSDBStatement extends AbstractStatement {
private TSDBJNIConnector connector;
private TSDBJNIConnector connector;
/** /**
* To store batched commands * To store batched commands
*/ */
protected List<String> batchedArgs; protected List<String> batchedArgs;
/**
* Timeout for a query
*/
protected int queryTimeout = 0;
private Long pSql = 0l;
/** /**
* Status of current statement * Status of current statement
*/ */
private boolean isClosed = true; private boolean isClosed;
private int affectedRows = 0; private int affectedRows = -1;
private TSDBConnection connection; private TSDBConnection connection;
private TSDBResultSet resultSet;
public void setConnection(TSDBConnection connection) { public void setConnection(TSDBConnection connection) {
this.connection = connection; this.connection = connection;
@ -50,220 +40,89 @@ public class TSDBStatement implements Statement {
TSDBStatement(TSDBConnection connection, TSDBJNIConnector connector) { TSDBStatement(TSDBConnection connection, TSDBJNIConnector connector) {
this.connection = connection; this.connection = connection;
this.connector = connector; this.connector = connector;
this.isClosed = false;
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
try {
return iface.cast(this);
} catch (ClassCastException cce) {
throw new SQLException("Unable to unwrap to " + iface.toString());
}
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return iface.isInstance(this);
} }
public ResultSet executeQuery(String sql) throws SQLException { public ResultSet executeQuery(String sql) throws SQLException {
if (isClosed()) { // check if closed
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
} //TODO: 如果在executeQuery方法中执行insert语句那么先执行了SQL再通过pSql来检查是否为一个insert语句但这个insert SQL已经执行成功了
// TODO make sure it is not a update query // execute query
pSql = this.connector.executeQuery(sql); long pSql = this.connector.executeQuery(sql);
long resultSetPointer = this.connector.getResultSet(); // if pSql is create/insert/update/delete/alter SQL
if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) { if (this.connector.isUpdateQuery(pSql)) {
this.connector.freeResultSet(pSql); this.connector.freeResultSet(pSql);
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY);
} }
// create/insert/update/delete/alter TSDBResultSet res = new TSDBResultSet(this, this.connector, pSql);
if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) {
this.connector.freeResultSet(pSql);
return null;
}
if (!this.connector.isUpdateQuery(pSql)) {
TSDBResultSet res = new TSDBResultSet(this.connector, resultSetPointer);
res.setBatchFetch(this.connection.getBatchFetch()); res.setBatchFetch(this.connection.getBatchFetch());
return res; return res;
} else {
this.connector.freeResultSet(pSql);
return null;
}
} }
public int executeUpdate(String sql) throws SQLException { public int executeUpdate(String sql) throws SQLException {
if (isClosed()) { if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
}
// TODO check if current query is update query long pSql = this.connector.executeQuery(sql);
pSql = this.connector.executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL
long resultSetPointer = this.connector.getResultSet(); if (!this.connector.isUpdateQuery(pSql)) {
if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) {
this.connector.freeResultSet(pSql); this.connector.freeResultSet(pSql);
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEUPDATE);
} }
int affectedRows = this.connector.getAffectedRows(pSql);
this.affectedRows = this.connector.getAffectedRows(pSql);
this.connector.freeResultSet(pSql); this.connector.freeResultSet(pSql);
return affectedRows;
return this.affectedRows;
}
public String getErrorMsg(long pSql) {
return this.connector.getErrMsg(pSql);
} }
public void close() throws SQLException { public void close() throws SQLException {
if (!isClosed) { if (!isClosed) {
if (!this.connector.isResultsetClosed()) { if (this.resultSet != null)
this.connector.freeResultSet(); this.resultSet.close();
}
isClosed = true; isClosed = true;
} }
} }
public int getMaxFieldSize() throws SQLException {
if (isClosed()) {
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
}
return 0;
}
public void setMaxFieldSize(int max) throws SQLException {
if (isClosed()) {
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
}
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getMaxRows() throws SQLException {
if (isClosed()) {
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
}
// always set maxRows to zero, meaning unlimitted rows in a resultSet
return 0;
}
public void setMaxRows(int max) throws SQLException {
if (isClosed()) {
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
}
// always set maxRows to zero, meaning unlimited rows in a resultSet
}
public void setEscapeProcessing(boolean enable) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getQueryTimeout() throws SQLException {
return queryTimeout;
}
public void setQueryTimeout(int seconds) throws SQLException {
this.queryTimeout = seconds;
}
public void cancel() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public SQLWarning getWarnings() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void clearWarnings() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void setCursorName(String name) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean execute(String sql) throws SQLException { public boolean execute(String sql) throws SQLException {
if (isClosed) { // check if closed
throw new SQLException("Invalid method call on a closed statement."); if (isClosed())
} throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
boolean res = true; // execute query
pSql = this.connector.executeQuery(sql); long pSql = this.connector.executeQuery(sql);
long resultSetPointer = this.connector.getResultSet(); // if pSql is create/insert/update/delete/alter SQL
if (this.connector.isUpdateQuery(pSql)) {
if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) { this.affectedRows = this.connector.getAffectedRows(pSql);
this.connector.freeResultSet(pSql); this.connector.freeResultSet(pSql);
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); return false;
} else if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) {
// no result set is retrieved
this.connector.freeResultSet(pSql);
res = false;
} }
return res; this.resultSet = new TSDBResultSet(this, this.connector, pSql);
this.resultSet.setBatchFetch(this.connection.getBatchFetch());
return true;
} }
public ResultSet getResultSet() throws SQLException { public ResultSet getResultSet() throws SQLException {
if (isClosed) { if (isClosed())
throw new SQLException("Invalid method call on a closed statement."); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
} // long resultSetPointer = connector.getResultSet();
long resultSetPointer = connector.getResultSet(); // TSDBResultSet resSet = null;
TSDBResultSet resSet = null; // if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) { // resSet = new TSDBResultSet(connector, resultSetPointer);
resSet = new TSDBResultSet(connector, resultSetPointer); // }
} return this.resultSet;
return resSet;
} }
public int getUpdateCount() throws SQLException { public int getUpdateCount() throws SQLException {
if (isClosed) { if (isClosed())
throw new SQLException("Invalid method call on a closed statement."); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
}
return this.affectedRows; return this.affectedRows;
} }
public boolean getMoreResults() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void setFetchDirection(int direction) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getFetchDirection() throws SQLException {
return ResultSet.FETCH_FORWARD;
// throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
/*
* used by spark
*/
public void setFetchSize(int rows) throws SQLException {
}
/*
* used by spark
*/
public int getFetchSize() throws SQLException {
return 4096;
}
public int getResultSetConcurrency() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getResultSetType() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void addBatch(String sql) throws SQLException { public void addBatch(String sql) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
if (batchedArgs == null) { if (batchedArgs == null) {
batchedArgs = new ArrayList<>(); batchedArgs = new ArrayList<>();
} }
@ -271,83 +130,41 @@ public class TSDBStatement implements Statement {
} }
public void clearBatch() throws SQLException { public void clearBatch() throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
if (batchedArgs != null)
batchedArgs.clear(); batchedArgs.clear();
} }
public int[] executeBatch() throws SQLException { public int[] executeBatch() throws SQLException {
if (isClosed) { if (isClosed())
throw new SQLException("Invalid method call on a closed statement."); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
} if (batchedArgs == null || batchedArgs.isEmpty())
if (batchedArgs == null) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_BATCH_IS_EMPTY);
throw new SQLException(TSDBConstants.WrapErrMsg("Batch is empty!"));
} else {
int[] res = new int[batchedArgs.size()]; int[] res = new int[batchedArgs.size()];
for (int i = 0; i < batchedArgs.size(); i++) { for (int i = 0; i < batchedArgs.size(); i++) {
res[i] = executeUpdate(batchedArgs.get(i)); boolean isSelect = execute(batchedArgs.get(i));
if (isSelect) {
res[i] = SUCCESS_NO_INFO;
} else {
res[i] = getUpdateCount();
}
} }
return res; return res;
} }
}
public Connection getConnection() throws SQLException { public Connection getConnection() throws SQLException {
if (this.connector != null) if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
if (this.connector == null)
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
return this.connection; return this.connection;
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean getMoreResults(int current) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public ResultSet getGeneratedKeys() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean execute(String sql, String[] columnNames) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getResultSetHoldability() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
} }
public boolean isClosed() throws SQLException { public boolean isClosed() throws SQLException {
return isClosed; return isClosed;
} }
public void setPoolable(boolean poolable) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean isPoolable() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public void closeOnCompletion() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public boolean isCloseOnCompletion() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
} }

View File

@ -50,7 +50,7 @@ public class TSDBSubscribe {
} else if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) { } else if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) {
return null; return null;
} else { } else {
return new TSDBResultSet(this.connecter, resultSetPointer); return new TSDBResultSet(null, this.connecter, resultSetPointer);
} }
} }

View File

@ -0,0 +1,21 @@
package com.taosdata.jdbc;
import java.sql.SQLException;
import java.sql.Wrapper;
public class WrapperImpl implements Wrapper {
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
try {
return iface.cast(this);
} catch (ClassCastException cce) {
throw new SQLException("Unable to unwrap to " + iface.toString());
}
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return iface.isInstance(this);
}
}

View File

@ -47,7 +47,7 @@ public class RestfulConnection implements Connection {
if (isClosed()) if (isClosed())
throw new SQLException(CONNECTION_IS_CLOSED); throw new SQLException(CONNECTION_IS_CLOSED);
//TODO: prepareStatement //TODO: prepareStatement
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -55,7 +55,7 @@ public class RestfulConnection implements Connection {
if (isClosed()) if (isClosed())
throw new SQLException(CONNECTION_IS_CLOSED); throw new SQLException(CONNECTION_IS_CLOSED);
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -72,7 +72,7 @@ public class RestfulConnection implements Connection {
if (isClosed()) if (isClosed())
throw new SQLException(CONNECTION_IS_CLOSED); throw new SQLException(CONNECTION_IS_CLOSED);
if (!autoCommit) if (!autoCommit)
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -162,7 +162,7 @@ public class RestfulConnection implements Connection {
case Connection.TRANSACTION_READ_COMMITTED: case Connection.TRANSACTION_READ_COMMITTED:
case Connection.TRANSACTION_REPEATABLE_READ: case Connection.TRANSACTION_REPEATABLE_READ:
case Connection.TRANSACTION_SERIALIZABLE: case Connection.TRANSACTION_SERIALIZABLE:
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
default: default:
throw new SQLException(TSDBConstants.INVALID_VARIABLES); throw new SQLException(TSDBConstants.INVALID_VARIABLES);
} }
@ -197,10 +197,10 @@ public class RestfulConnection implements Connection {
throw new SQLException(CONNECTION_IS_CLOSED); throw new SQLException(CONNECTION_IS_CLOSED);
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) { if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
return createStatement(); return createStatement();
} }
@ -221,7 +221,7 @@ public class RestfulConnection implements Connection {
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
throw new SQLFeatureNotSupportedException(TSDBConstants.INVALID_VARIABLES); throw new SQLFeatureNotSupportedException(TSDBConstants.INVALID_VARIABLES);
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -252,7 +252,7 @@ public class RestfulConnection implements Connection {
if (isClosed()) if (isClosed())
throw new SQLException(CONNECTION_IS_CLOSED); throw new SQLException(CONNECTION_IS_CLOSED);
if (holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT) if (holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT)
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -269,7 +269,7 @@ public class RestfulConnection implements Connection {
if (getAutoCommit()) if (getAutoCommit())
throw new SQLException(TSDBConstants.INVALID_VARIABLES); throw new SQLException(TSDBConstants.INVALID_VARIABLES);
//nothing to do //nothing to do
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -279,7 +279,7 @@ public class RestfulConnection implements Connection {
if (getAutoCommit()) if (getAutoCommit())
throw new SQLException(TSDBConstants.INVALID_VARIABLES); throw new SQLException(TSDBConstants.INVALID_VARIABLES);
//nothing to do //nothing to do
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -289,68 +289,68 @@ public class RestfulConnection implements Connection {
if (getAutoCommit()) if (getAutoCommit())
throw new SQLException(TSDBConstants.INVALID_VARIABLES); throw new SQLException(TSDBConstants.INVALID_VARIABLES);
//nothing to do //nothing to do
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException { public void releaseSavepoint(Savepoint savepoint) throws SQLException {
if (isClosed()) if (isClosed())
throw new SQLException(CONNECTION_IS_CLOSED); throw new SQLException(CONNECTION_IS_CLOSED);
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
return createStatement(resultSetType, resultSetConcurrency); return createStatement(resultSetType, resultSetConcurrency);
} }
@Override @Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
return prepareStatement(sql, resultSetType, resultSetConcurrency); return prepareStatement(sql, resultSetType, resultSetConcurrency);
} }
@Override @Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public Clob createClob() throws SQLException { public Clob createClob() throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public Blob createBlob() throws SQLException { public Blob createBlob() throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public NClob createNClob() throws SQLException { public NClob createNClob() throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public SQLXML createSQLXML() throws SQLException { public SQLXML createSQLXML() throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -399,12 +399,12 @@ public class RestfulConnection implements Connection {
@Override @Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException { public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException { public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override
@ -442,7 +442,7 @@ public class RestfulConnection implements Connection {
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
if (isClosed()) if (isClosed())
throw new SQLException(CONNECTION_IS_CLOSED); throw new SQLException(CONNECTION_IS_CLOSED);
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
} }
@Override @Override

View File

@ -2,7 +2,7 @@ package com.taosdata.jdbc.rs;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.taosdata.jdbc.AbstractTaosDriver; import com.taosdata.jdbc.AbstractDriver;
import com.taosdata.jdbc.TSDBConstants; import com.taosdata.jdbc.TSDBConstants;
import com.taosdata.jdbc.TSDBDriver; import com.taosdata.jdbc.TSDBDriver;
import com.taosdata.jdbc.rs.util.HttpClientPoolUtil; import com.taosdata.jdbc.rs.util.HttpClientPoolUtil;
@ -11,7 +11,7 @@ import java.sql.*;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Logger; import java.util.logging.Logger;
public class RestfulDriver extends AbstractTaosDriver { public class RestfulDriver extends AbstractDriver {
private static final String URL_PREFIX = "jdbc:TAOS-RS://"; private static final String URL_PREFIX = "jdbc:TAOS-RS://";

View File

@ -2,6 +2,7 @@ package com.taosdata.jdbc.rs;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.taosdata.jdbc.AbstractStatement;
import com.taosdata.jdbc.TSDBConstants; import com.taosdata.jdbc.TSDBConstants;
import com.taosdata.jdbc.rs.util.HttpClientPoolUtil; import com.taosdata.jdbc.rs.util.HttpClientPoolUtil;
import com.taosdata.jdbc.utils.SqlSyntaxValidator; import com.taosdata.jdbc.utils.SqlSyntaxValidator;
@ -12,7 +13,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class RestfulStatement implements Statement { public class RestfulStatement extends AbstractStatement {
private boolean closed; private boolean closed;
private String database; private String database;
@ -20,7 +21,6 @@ public class RestfulStatement implements Statement {
private volatile RestfulResultSet resultSet; private volatile RestfulResultSet resultSet;
private volatile int affectedRows; private volatile int affectedRows;
private volatile boolean closeOnCompletion;
public RestfulStatement(RestfulConnection conn, String database) { public RestfulStatement(RestfulConnection conn, String database) {
this.conn = conn; this.conn = conn;
@ -104,85 +104,6 @@ public class RestfulStatement implements Statement {
} }
} }
@Override
public int getMaxFieldSize() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return TSDBConstants.maxFieldSize;
}
@Override
public void setMaxFieldSize(int max) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (max < 0)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
// nothing to do
}
@Override
public int getMaxRows() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return 0;
}
@Override
public void setMaxRows(int max) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (max < 0)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
// nothing to do
}
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
}
@Override
public int getQueryTimeout() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return 0;
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (seconds < 0)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
}
@Override
public void cancel() throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override
public SQLWarning getWarnings() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return null;
}
@Override
public void clearWarnings() throws SQLException {
// nothing to do
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
}
@Override
public void setCursorName(String name) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override @Override
public boolean execute(String sql) throws SQLException { public boolean execute(String sql) throws SQLException {
if (isClosed()) if (isClosed())
@ -271,53 +192,6 @@ public class RestfulStatement implements Statement {
return this.affectedRows; return this.affectedRows;
} }
@Override
public boolean getMoreResults() throws SQLException {
return getMoreResults(CLOSE_CURRENT_RESULT);
}
@Override
public void setFetchDirection(int direction) throws SQLException {
if (direction != ResultSet.FETCH_FORWARD && direction != ResultSet.FETCH_REVERSE && direction != ResultSet.FETCH_UNKNOWN)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
this.resultSet.setFetchDirection(direction);
}
@Override
public int getFetchDirection() throws SQLException {
return this.resultSet.getFetchDirection();
}
@Override
public void setFetchSize(int rows) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (rows < 0)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
//nothing to do
}
@Override
public int getFetchSize() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return 0;
}
@Override
public int getResultSetConcurrency() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.resultSet.getConcurrency();
}
@Override
public int getResultSetType() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.resultSet.getType();
}
@Override @Override
public void addBatch(String sql) throws SQLException { public void addBatch(String sql) throws SQLException {
if (isClosed()) if (isClosed())
@ -343,115 +217,10 @@ public class RestfulStatement implements Statement {
return this.conn; return this.conn;
} }
@Override
public boolean getMoreResults(int current) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (resultSet == null)
return false;
// switch (current) {
// case CLOSE_CURRENT_RESULT:
// resultSet.close();
// break;
// case KEEP_CURRENT_RESULT:
// break;
// case CLOSE_ALL_RESULTS:
// resultSet.close();
// break;
// default:
// throw new SQLException(TSDBConstants.INVALID_VARIABLES);
// }
// return next;
return false;
}
@Override
public ResultSet getGeneratedKeys() throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override
public boolean execute(String sql, String[] columnNames) throws SQLException {
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
@Override
public int getResultSetHoldability() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.resultSet.getHoldability();
}
@Override @Override
public boolean isClosed() throws SQLException { public boolean isClosed() throws SQLException {
return closed; return closed;
} }
@Override
public void setPoolable(boolean poolable) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
//nothing to do
}
@Override
public boolean isPoolable() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return false;
}
@Override
public void closeOnCompletion() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
this.closeOnCompletion = true;
}
@Override
public boolean isCloseOnCompletion() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.closeOnCompletion;
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
try {
return iface.cast(this);
} catch (ClassCastException cce) {
throw new SQLException("Unable to unwrap to " + iface.toString());
}
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return iface.isInstance(this);
}
} }

View File

@ -7,6 +7,7 @@ import org.junit.Test;
import javax.sql.rowset.serial.SerialBlob; import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialClob; import javax.sql.rowset.serial.SerialClob;
import java.io.UnsupportedEncodingException;
import java.sql.*; import java.sql.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Properties; import java.util.Properties;
@ -39,7 +40,6 @@ public class ResultSetTest {
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
return; return;
} }
} }
@Test @Test
@ -54,51 +54,38 @@ public class ResultSetTest {
short v6 = 12; short v6 = 12;
boolean v7 = false; boolean v7 = false;
String v8 = "TDengine is powerful"; String v8 = "TDengine is powerful";
sql = "insert into " + dbName + "." + tName + " values (" + ts + "," + v1 + "," + v2 + "," + v3 + "," + v4 sql = "insert into " + dbName + "." + tName + " values (" + ts + "," + v1 + "," + v2 + "," + v3 + "," + v4
+ ",\"" + v5 + "\"," + v6 + "," + v7 + ",\"" + v8 + "\")"; + ",\"" + v5 + "\"," + v6 + "," + v7 + ",\"" + v8 + "\")";
try { try {
statement.executeUpdate(sql); statement.executeUpdate(sql);
assertEquals(1, statement.getUpdateCount()); assertEquals(1, statement.getUpdateCount());
} catch (SQLException e) { } catch (SQLException e) {
assert false : "insert error " + e.getMessage(); assert false : "insert error " + e.getMessage();
} }
try { try {
statement.executeQuery("select * from " + dbName + "." + tName + " where ts = " + ts); statement.execute("select * from " + dbName + "." + tName + " where ts = " + ts);
resSet = statement.getResultSet(); resSet = statement.getResultSet();
System.out.println(((TSDBResultSet) resSet).getRowData()); System.out.println(((TSDBResultSet) resSet).getRowData());
while (resSet.next()) { while (resSet.next()) {
assertEquals(ts, resSet.getLong(1)); assertEquals(ts, resSet.getLong(1));
assertEquals(ts, resSet.getLong("ts")); assertEquals(ts, resSet.getLong("ts"));
System.out.println(resSet.getTimestamp(1)); System.out.println(resSet.getTimestamp(1));
assertEquals(v1, resSet.getInt(2)); assertEquals(v1, resSet.getInt(2));
assertEquals(v1, resSet.getInt("k1")); assertEquals(v1, resSet.getInt("k1"));
assertEquals(v2, resSet.getLong(3)); assertEquals(v2, resSet.getLong(3));
assertEquals(v2, resSet.getLong("k2")); assertEquals(v2, resSet.getLong("k2"));
assertEquals(v3, resSet.getFloat(4), 7); assertEquals(v3, resSet.getFloat(4), 7);
assertEquals(v3, resSet.getFloat("k3"), 7); assertEquals(v3, resSet.getFloat("k3"), 7);
assertEquals(v4, resSet.getDouble(5), 13); assertEquals(v4, resSet.getDouble(5), 13);
assertEquals(v4, resSet.getDouble("k4"), 13); assertEquals(v4, resSet.getDouble("k4"), 13);
assertEquals(v5, resSet.getString(6)); assertEquals(v5, resSet.getString(6));
assertEquals(v5, resSet.getString("k5")); assertEquals(v5, resSet.getString("k5"));
assertEquals(v6, resSet.getShort(7)); assertEquals(v6, resSet.getShort(7));
assertEquals(v6, resSet.getShort("k6")); assertEquals(v6, resSet.getShort("k6"));
assertEquals(v7, resSet.getBoolean(8)); assertEquals(v7, resSet.getBoolean(8));
assertEquals(v7, resSet.getBoolean("k7")); assertEquals(v7, resSet.getBoolean("k7"));
assertEquals(v8, resSet.getString(9)); assertEquals(v8, resSet.getString(9));
assertEquals(v8, resSet.getString("k8")); assertEquals(v8, resSet.getString("k8"));
resSet.getBytes(9); resSet.getBytes(9);
resSet.getObject(6); resSet.getObject(6);
resSet.getObject("k8"); resSet.getObject("k8");
@ -111,684 +98,145 @@ public class ResultSetTest {
} }
} }
@Test @Test(expected = SQLException.class)
public void testUnsupport() throws SQLException { public void testUnsupport() throws SQLException, UnsupportedEncodingException {
statement.executeQuery("show databases"); statement.execute("show databases");
resSet = statement.getResultSet(); resSet = statement.getResultSet();
Assert.assertNotNull(resSet.unwrap(TSDBResultSet.class)); Assert.assertNotNull(resSet.unwrap(TSDBResultSet.class));
Assert.assertTrue(resSet.isWrapperFor(TSDBResultSet.class)); Assert.assertTrue(resSet.isWrapperFor(TSDBResultSet.class));
try {
resSet.getAsciiStream(0);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getUnicodeStream(null); resSet.getUnicodeStream(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getBinaryStream(null); resSet.getBinaryStream(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getAsciiStream(""); resSet.getAsciiStream("");
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getUnicodeStream(null); resSet.getUnicodeStream(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getBinaryStream(null); resSet.getBinaryStream(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getWarnings(); resSet.getWarnings();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.clearWarnings(); resSet.clearWarnings();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getCursorName(); resSet.getCursorName();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getCharacterStream(null); resSet.getCharacterStream(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getCharacterStream(null); resSet.getCharacterStream(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.isBeforeFirst(); resSet.isBeforeFirst();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.isAfterLast(); resSet.isAfterLast();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.isFirst(); resSet.isFirst();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.isLast(); resSet.isLast();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.beforeFirst(); resSet.beforeFirst();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.afterLast(); resSet.afterLast();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.first(); resSet.first();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.last(); resSet.last();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getRow(); resSet.getRow();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.absolute(1); resSet.absolute(1);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.relative(1); resSet.relative(1);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.previous(); resSet.previous();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.setFetchDirection(0); resSet.setFetchDirection(0);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getFetchDirection(); resSet.getFetchDirection();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.setFetchSize(0); resSet.setFetchSize(0);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getFetchSize(); resSet.getFetchSize();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getConcurrency(); resSet.getConcurrency();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.rowUpdated(); resSet.rowUpdated();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.rowInserted(); resSet.rowInserted();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.rowDeleted(); resSet.rowDeleted();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateNull(null); resSet.updateNull(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBoolean(0, true); resSet.updateBoolean(0, true);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateByte(0, (byte) 2); resSet.updateByte(0, (byte) 2);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateShort(0, (short) 1); resSet.updateShort(0, (short) 1);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateInt(0, 0); resSet.updateInt(0, 0);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateLong(0, 0l); resSet.updateLong(0, 0l);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateFloat(0, 3.14f); resSet.updateFloat(0, 3.14f);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateDouble(0, 3.1415); resSet.updateDouble(0, 3.1415);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBigDecimal(null, null); resSet.updateBigDecimal(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateString(null, null); resSet.updateString(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBytes(null, null); resSet.updateBytes(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateDate(null, null); resSet.updateDate(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateTime(null, null); resSet.updateTime(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateTimestamp(null, null); resSet.updateTimestamp(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateAsciiStream(null, null); resSet.updateAsciiStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBinaryStream(null, null); resSet.updateBinaryStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateCharacterStream(null, null); resSet.updateCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateObject(null, null); resSet.updateObject(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateObject(null, null); resSet.updateObject(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateNull(null); resSet.updateNull(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBoolean("", false); resSet.updateBoolean("", false);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateByte("", (byte) 1); resSet.updateByte("", (byte) 1);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateShort("", (short) 1); resSet.updateShort("", (short) 1);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateInt("", 0); resSet.updateInt("", 0);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateLong("", 0l); resSet.updateLong("", 0l);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateFloat("", 3.14f); resSet.updateFloat("", 3.14f);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateDouble("", 3.1415); resSet.updateDouble("", 3.1415);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBigDecimal(null, null); resSet.updateBigDecimal(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateString(null, null); resSet.updateString(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBytes(null, null); resSet.updateBytes(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateDate(null, null); resSet.updateDate(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateTime(null, null); resSet.updateTime(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateTimestamp(null, null); resSet.updateTimestamp(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateAsciiStream(null, null); resSet.updateAsciiStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBinaryStream(null, null); resSet.updateBinaryStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateCharacterStream(null, null); resSet.updateCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateObject(null, null); resSet.updateObject(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateObject(null, null); resSet.updateObject(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.insertRow(); resSet.insertRow();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateRow(); resSet.updateRow();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.deleteRow(); resSet.deleteRow();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.refreshRow(); resSet.refreshRow();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.cancelRowUpdates(); resSet.cancelRowUpdates();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.moveToInsertRow(); resSet.moveToInsertRow();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.moveToCurrentRow(); resSet.moveToCurrentRow();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getStatement(); resSet.getStatement();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getObject(0, new HashMap<>()); resSet.getObject(0, new HashMap<>());
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getRef(null); resSet.getRef(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getBlob(null); resSet.getBlob(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getClob(null); resSet.getClob(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getArray(null); resSet.getArray(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getObject("", new HashMap<>()); resSet.getObject("", new HashMap<>());
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getRef(null); resSet.getRef(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getBlob(null); resSet.getBlob(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getClob(null); resSet.getClob(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getArray(null); resSet.getArray(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getDate(null, null); resSet.getDate(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getDate(null, null); resSet.getDate(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getTime(null, null); resSet.getTime(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getTime(null, null); resSet.getTime(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getTimestamp(null, null); resSet.getTimestamp(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getTimestamp(null, null); resSet.getTimestamp(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getURL(null); resSet.getURL(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getURL(null); resSet.getURL(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateRef(null, null); resSet.updateRef(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateRef(null, null); resSet.updateRef(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBlob(0, new SerialBlob("".getBytes("UTF8"))); resSet.updateBlob(0, new SerialBlob("".getBytes("UTF8")));
} catch (Exception e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBlob("", new SerialBlob("".getBytes("UTF8"))); resSet.updateBlob("", new SerialBlob("".getBytes("UTF8")));
} catch (Exception e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateClob("", new SerialClob("".toCharArray())); resSet.updateClob("", new SerialClob("".toCharArray()));
} catch (Exception e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateClob(0, new SerialClob("".toCharArray())); resSet.updateClob(0, new SerialClob("".toCharArray()));
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateArray(null, null); resSet.updateArray(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateArray(null, null); resSet.updateArray(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getRowId(null); resSet.getRowId(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getRowId(null); resSet.getRowId(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateRowId(null, null); resSet.updateRowId(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateRowId(null, null); resSet.updateRowId(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getHoldability(); resSet.getHoldability();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateNString(null, null); resSet.updateNString(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateNString(null, null); resSet.updateNString(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getNClob(null); resSet.getNClob(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getNClob(null); resSet.getNClob(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getSQLXML(null); resSet.getSQLXML(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getSQLXML(null); resSet.getSQLXML(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateSQLXML(null, null); resSet.updateSQLXML(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateSQLXML(null, null); resSet.updateSQLXML(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getNCharacterStream(null); resSet.getNCharacterStream(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.getNCharacterStream(null); resSet.getNCharacterStream(null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateNCharacterStream(null, null); resSet.updateNCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateNCharacterStream(null, null); resSet.updateNCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateAsciiStream(null, null); resSet.updateAsciiStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBinaryStream(null, null); resSet.updateBinaryStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateCharacterStream(null, null); resSet.updateCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateAsciiStream(null, null); resSet.updateAsciiStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBinaryStream(null, null); resSet.updateBinaryStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateCharacterStream(null, null); resSet.updateCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateNCharacterStream(null, null); resSet.updateNCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateNCharacterStream(null, null); resSet.updateNCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateAsciiStream(null, null); resSet.updateAsciiStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBinaryStream(null, null); resSet.updateBinaryStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateCharacterStream(null, null); resSet.updateCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateAsciiStream(null, null); resSet.updateAsciiStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateBinaryStream(null, null); resSet.updateBinaryStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
try {
resSet.updateCharacterStream(null, null); resSet.updateCharacterStream(null, null);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
}
} }
@Test @Test
@ -816,5 +264,4 @@ public class ResultSetTest {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View File

@ -8,9 +8,6 @@ import org.junit.Test;
import java.sql.*; import java.sql.*;
import java.util.Properties; import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class StatementTest { public class StatementTest {
static Connection connection = null; static Connection connection = null;
static Statement statement = null; static Statement statement = null;
@ -58,12 +55,12 @@ public class StatementTest {
statement.executeUpdate("create database if not exists " + dbName); statement.executeUpdate("create database if not exists " + dbName);
statement.executeUpdate("create table if not exists " + dbName + "." + tName + "(ts timestamp, k1 int)"); statement.executeUpdate("create table if not exists " + dbName + "." + tName + "(ts timestamp, k1 int)");
statement.executeUpdate("insert into " + dbName + "." + tName + " values (" + ts + ", 1)"); statement.executeUpdate("insert into " + dbName + "." + tName + " values (" + ts + ", 1)");
statement.executeQuery("select * from " + dbName + "." + tName); statement.execute("select * from " + dbName + "." + tName);
ResultSet resultSet = statement.getResultSet(); ResultSet resultSet = statement.getResultSet();
assertTrue(null != resultSet); Assert.assertNotNull(resultSet);
boolean isClosed = statement.isClosed(); boolean isClosed = statement.isClosed();
assertEquals(false, isClosed); Assert.assertEquals(false, isClosed);
} }
@Test(expected = SQLException.class) @Test(expected = SQLException.class)

View File

@ -9,13 +9,14 @@ import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.TimeUnit;
public class SubscribeTest { public class SubscribeTest {
Connection connection; Connection connection;
Statement statement; Statement statement;
String dbName = "test"; String dbName = "test";
String tName = "t0"; String tName = "t0";
String host = "localhost"; String host = "127.0.0.1";
String topic = "test"; String topic = "test";
@Before @Before
@ -23,15 +24,15 @@ public class SubscribeTest {
try { try {
Class.forName("com.taosdata.jdbc.TSDBDriver"); Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host);
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("create database if not exists " + dbName); statement.execute("drop database if exists " + dbName);
statement.executeUpdate("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)"); statement.execute("create database if not exists " + dbName);
statement.execute("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)");
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
ts += i; ts += i;
@ -45,44 +46,40 @@ public class SubscribeTest {
} }
@Test @Test
public void subscribe() throws Exception { public void subscribe() {
TSDBSubscribe subscribe = null;
try { try {
String rawSql = "select * from " + dbName + "." + tName + ";"; String rawSql = "select * from " + dbName + "." + tName + ";";
System.out.println(rawSql); System.out.println(rawSql);
subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false); TSDBSubscribe subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false);
int a = 0; int a = 0;
while (true) { while (true) {
Thread.sleep(900); TimeUnit.MILLISECONDS.sleep(1000);
TSDBResultSet resSet = subscribe.consume(); TSDBResultSet resSet = subscribe.consume();
while (resSet.next()) { while (resSet.next()) {
for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) { for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) {
System.out.printf(i + ": " + resSet.getString(i) + "\t"); System.out.printf(i + ": " + resSet.getString(i) + "\t");
} }
System.out.println("\n======" + a + "=========="); System.out.println("\n======" + a + "==========");
} }
resSet.close();
a++; a++;
if (a >= 2) { if (a >= 2) {
break; break;
} }
// resSet.close();
} }
subscribe.close(true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (null != subscribe) {
subscribe.close(true);
}
} }
} }
@After @After
public void close() { public void close() {
try { try {
statement.executeQuery("drop database " + dbName); statement.execute("drop database " + dbName);
if (statement != null) if (statement != null)
statement.close(); statement.close();
if (connection != null) if (connection != null)

View File

@ -0,0 +1,234 @@
package com.taosdata.jdbc;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.sql.*;
import java.util.Properties;
import java.util.UUID;
public class TSDBStatementTest {
private static final String host = "127.0.0.1";
private static Connection conn;
private static Statement stmt;
@Test
public void executeQuery() {
try {
ResultSet rs = stmt.executeQuery("show databases");
Assert.assertNotNull(rs);
ResultSetMetaData meta = rs.getMetaData();
while (rs.next()) {
for (int i = 1; i <= meta.getColumnCount(); i++) {
System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t");
}
System.out.println();
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void executeUpdate() {
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
try {
int affectRows = stmt.executeUpdate("create database " + dbName);
Assert.assertEquals(0, affectRows);
affectRows = stmt.executeUpdate("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
Assert.assertEquals(0, affectRows);
affectRows = stmt.executeUpdate("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
Assert.assertEquals(1, affectRows);
affectRows = stmt.executeUpdate("drop database " + dbName);
Assert.assertEquals(0, affectRows);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void close() {
}
@Test
public void execute() {
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
try {
boolean isSelect = stmt.execute("create database " + dbName);
Assert.assertEquals(false, isSelect);
int affectedRows = stmt.getUpdateCount();
Assert.assertEquals(0, affectedRows);
isSelect = stmt.execute("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
Assert.assertEquals(false, isSelect);
affectedRows = stmt.getUpdateCount();
Assert.assertEquals(0, affectedRows);
isSelect = stmt.execute("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
Assert.assertEquals(false, isSelect);
affectedRows = stmt.getUpdateCount();
Assert.assertEquals(1, affectedRows);
isSelect = stmt.execute("select * from " + dbName + ".weather");
Assert.assertEquals(true, isSelect);
isSelect = stmt.execute("drop database " + dbName);
Assert.assertEquals(false, isSelect);
affectedRows = stmt.getUpdateCount();
Assert.assertEquals(0, affectedRows);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void getResultSet() {
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
try {
boolean isSelect = stmt.execute("create database " + dbName);
Assert.assertEquals(false, isSelect);
int affectedRows = stmt.getUpdateCount();
Assert.assertEquals(0, affectedRows);
isSelect = stmt.execute("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
Assert.assertEquals(false, isSelect);
affectedRows = stmt.getUpdateCount();
Assert.assertEquals(0, affectedRows);
isSelect = stmt.execute("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
Assert.assertEquals(false, isSelect);
affectedRows = stmt.getUpdateCount();
Assert.assertEquals(1, affectedRows);
isSelect = stmt.execute("select * from " + dbName + ".weather");
Assert.assertEquals(true, isSelect);
ResultSet rs = stmt.getResultSet();
Assert.assertNotNull(rs);
ResultSetMetaData meta = rs.getMetaData();
Assert.assertEquals(3, meta.getColumnCount());
int count = 0;
while (rs.next()) {
for (int i = 1; i <= meta.getColumnCount(); i++) {
System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t");
}
System.out.println();
count++;
}
Assert.assertEquals(1, count);
isSelect = stmt.execute("drop database " + dbName);
Assert.assertEquals(false, isSelect);
affectedRows = stmt.getUpdateCount();
Assert.assertEquals(0, affectedRows);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void getUpdateCount() {
execute();
}
@Test
public void addBatch() {
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
try {
stmt.addBatch("create database " + dbName);
stmt.addBatch("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
stmt.addBatch("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
stmt.addBatch("select * from " + dbName + ".weather");
stmt.addBatch("drop database " + dbName);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void clearBatch() {
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
try {
stmt.clearBatch();
stmt.addBatch("create database " + dbName);
stmt.addBatch("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
stmt.addBatch("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
stmt.addBatch("select * from " + dbName + ".weather");
stmt.addBatch("drop database " + dbName);
stmt.clearBatch();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void executeBatch() {
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
try {
stmt.addBatch("create database " + dbName);
stmt.addBatch("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
stmt.addBatch("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
stmt.addBatch("select * from " + dbName + ".weather");
stmt.addBatch("drop database " + dbName);
int[] results = stmt.executeBatch();
Assert.assertEquals(0, results[0]);
Assert.assertEquals(0, results[1]);
Assert.assertEquals(1, results[2]);
Assert.assertEquals(Statement.SUCCESS_NO_INFO, results[3]);
Assert.assertEquals(0, results[4]);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void getConnection() {
try {
Connection connection = stmt.getConnection();
Assert.assertNotNull(connection);
Assert.assertTrue(this.conn == connection);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void isClosed() {
try {
Assert.assertEquals(false, stmt.isClosed());
} catch (SQLException e) {
e.printStackTrace();
}
}
@BeforeClass
public static void beforeClass() {
try {
Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties();
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", properties);
stmt = conn.createStatement();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
@AfterClass
public static void afterClass() {
try {
if (stmt != null)
stmt.close();
if (conn != null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,187 @@
package com.taosdata.jdbc.cases;
import org.junit.BeforeClass;
import org.junit.Test;
import java.sql.*;
import java.util.Properties;
public class InvalidResultSetPointerTest {
private static String host = "127.0.0.1";
private static final String dbName = "test";
private static final String stbName = "stb";
private static final String tbName = "tb";
private static Connection connection;
private static int numOfSTb = 30000;
private static int numOfTb = 3;
private static int numOfThreads = 100;
@Test
public void test() throws SQLException {
execute("drop database if exists " + dbName);
execute("create database if not exists " + dbName);
execute("use " + dbName);
createSTable();
createTable();
insert();
selectMultiThreading();
close();
}
private void insert() {
for (int i = 0; i < numOfSTb; i++) {
for (int j = 0; j < numOfTb; j++) {
final String sql = "INSERT INTO " + dbName + "." + tbName + i + "_" + j + " (ts, temperature, humidity, name) values(now, 20.5, 34, \"" + i + "\")";
System.out.println(sql);
execute(sql);
}
}
}
private void createSTable() {
for (int i = 0; i < numOfSTb; i++) {
final String sql = "create table if not exists " + dbName + "." + stbName + i + " (ts timestamp, temperature float, humidity int, name BINARY(" + (i % 73 + 10) + ")) TAGS (tag1 INT)";
execute(sql);
}
}
private void createTable() {
for (int i = 0; i < numOfSTb; i++) {
for (int j = 0; j < numOfTb; j++) {
final String sql = "create table if not exists " + dbName + "." + tbName + i + "_" + j + " USING " + stbName + i + " TAGS(" + j + ")";
execute(sql);
}
}
}
private void close() throws SQLException {
if (connection != null) {
this.connection.close();
System.out.println("connection closed.");
}
}
private void selectMultiThreading() {
int a = numOfSTb / numOfThreads;
if (a < 1) {
numOfThreads = numOfSTb;
a = 1;
}
int b = 0;
if (numOfThreads != 0) {
b = numOfSTb % numOfThreads;
}
multiThreadingClass instance[] = new multiThreadingClass[numOfThreads];
int last = 0;
for (int i = 0; i < numOfThreads; i++) {
instance[i] = new multiThreadingClass();
instance[i].id = i;
instance[i].from = last;
if (i < b) {
instance[i].to = last + a;
} else {
instance[i].to = last + a - 1;
}
last = instance[i].to + 1;
instance[i].numOfTb = numOfTb;
instance[i].connection = connection;
instance[i].dbName = dbName;
instance[i].tbName = tbName;
instance[i].start();
}
for (int i = 0; i < numOfThreads; i++) {
try {
instance[i].join();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
@BeforeClass
public static void beforeClass() {
try {
String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata";
Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties();
properties.setProperty("charset", "UTF-8");
properties.setProperty("locale", "en_US.UTF-8");
properties.setProperty("timezone", "UTC-8");
System.out.println("get connection starting...");
connection = DriverManager.getConnection(url, properties);
if (connection != null)
System.out.println("[ OK ] Connection established.");
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
}
private void execute(String sql) {
try (Statement statement = connection.createStatement()) {
long start = System.currentTimeMillis();
statement.execute(sql);
long end = System.currentTimeMillis();
printSql(sql, (end - start));
} catch (SQLException e) {
e.printStackTrace();
}
}
private void printSql(String sql, long cost) {
System.out.println("time cost: " + cost + " ms, execute statement ====> " + sql);
}
private void executeQuery(String sql) {
try (Statement statement = connection.createStatement()) {
long start = System.currentTimeMillis();
ResultSet resultSet = statement.executeQuery(sql);
long end = System.currentTimeMillis();
printSql(sql, (end - start));
// printResult(resultSet);
resultSet.close();
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
class multiThreadingClass extends Thread {
public int id;
public int from, to;
public int numOfTb;
public Connection connection;
public String dbName;
public String tbName;
public void run() {
System.out.println("ID: " + id + " from: " + from + " to: " + to);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println("Thread " + id + " interrupted.");
}
for (int i = from; i < to; i++) {
for (int j = 0; j < numOfTb; j++) {
if (j % 1000 == 0) {
try {
System.out.print(id + "s.");
Thread.sleep(1);
} catch (InterruptedException e) {
System.out.println("Thread " + id + " interrupted.");
}
}
final String sql = "select last_row(humidity) from " + dbName + "." + tbName + i + "_" + j;
executeQuery(sql);
}
}
}
}
}

View File

@ -259,10 +259,12 @@ public class RestfulResultSetTest {
rs.previous(); rs.previous();
} }
@Test(expected = SQLException.class) @Test
public void setFetchDirection() throws SQLException { public void setFetchDirection() throws SQLException {
rs.setFetchDirection(ResultSet.FETCH_FORWARD); rs.setFetchDirection(ResultSet.FETCH_FORWARD);
Assert.assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
rs.setFetchDirection(ResultSet.FETCH_UNKNOWN); rs.setFetchDirection(ResultSet.FETCH_UNKNOWN);
Assert.assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
} }
@Test @Test
@ -270,14 +272,15 @@ public class RestfulResultSetTest {
Assert.assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection()); Assert.assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
} }
@Test(expected = SQLException.class) @Test
public void setFetchSize() throws SQLException { public void setFetchSize() throws SQLException {
rs.setFetchSize(0); rs.setFetchSize(0);
Assert.assertEquals(0, rs.getFetchSize());
} }
@Test @Test
public void getFetchSize() throws SQLException { public void getFetchSize() throws SQLException {
Assert.assertEquals(1, rs.getFetchSize()); Assert.assertEquals(0, rs.getFetchSize());
} }
@Test @Test
@ -526,9 +529,12 @@ public class RestfulResultSetTest {
rs.updateSQLXML(1, null); rs.updateSQLXML(1, null);
} }
@Test(expected = SQLFeatureNotSupportedException.class) @Test
public void getNString() throws SQLException { public void getNString() throws SQLException {
rs.getNString("f1"); String f10 = rs.getNString("f10");
Assert.assertEquals("涛思数据", f10);
f10 = rs.getNString(10);
Assert.assertEquals("涛思数据", f10);
} }
@Test(expected = SQLFeatureNotSupportedException.class) @Test(expected = SQLFeatureNotSupportedException.class)

View File

@ -356,7 +356,7 @@ static int32_t mnodeGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
pShow->bytes[cols] = 8; pShow->bytes[cols] = 8;
pSchema[cols].type = TSDB_DATA_TYPE_BIGINT; pSchema[cols].type = TSDB_DATA_TYPE_BIGINT;
strcpy(pSchema[cols].name, "time(us)"); strcpy(pSchema[cols].name, "time");
pSchema[cols].bytes = htons(pShow->bytes[cols]); pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++; cols++;

View File

@ -7649,7 +7649,10 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co
*continueExec = true; *continueExec = true;
qDebug("QInfo:%p has more results to retrieve", pQInfo); qDebug("QInfo:%p has more results to retrieve", pQInfo);
} }
if (pQInfo->code != TSDB_CODE_SUCCESS) {
rpcFreeCont(*pRsp);
*pRsp = NULL;
}
return pQInfo->code; return pQInfo->code;
} }

View File

@ -0,0 +1,38 @@
install build environment
===
/usr/bin/python3 -m pip install -r requirements.txt
run python version taosdemo
===
Usage: ./taosdemo.py [OPTION...]
Author: Shuduo Sang <sangshuduo@gmail.com>
-H, --help Show usage.
-N, --native flag, Use native interface if set. Default is using RESTful interface.
-h, --host <hostname> host, The host to connect to TDengine. Default is localhost.
-p, --port <port> port, The TCP/IP port number to use for the connection. Default is 0.
-u, --user <username> user, The user name to use when connecting to the server. Default is 'root'.
-P, --password <password> password, The password to use when connecting to the server. Default is 'taosdata'.
-l, --colsPerRec <number> num_of_columns_per_record, The number of columns per record. Default is 3.
-d, --dbname <dbname> database, Destination database. Default is 'test'.
-a, --replica <replications> replica, Set the replica parameters of the database, Default 1, min: 1, max: 5.
-m, --tbname <table prefix> table_prefix, Table prefix name. Default is 't'.
-M, --stable flag, Use super table. Default is no
-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is 'st'
-Q, --query <DEFAULT | NO | command> query, Execute query command. set 'DEFAULT' means select * from each table
-T, --threads <number> num_of_threads, The number of threads. Default is 1.
-C, --processes <number> num_of_processes, The number of threads. Default is 1.
-r, --batch <number> num_of_records_per_req, The number of records per request. Default is 1000.
-t, --numOfTb <number> num_of_tables, The number of tables. Default is 1.
-n, --numOfRec <number> num_of_records_per_table, The number of records per table. Default is 1.
-c, --config <path> config_directory, Configuration directory. Default is '/etc/taos/'.
-x, --inserOnly flag, Insert only flag.
-O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order.
-R, --rateOOOO <number> rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50.
-D, --deleteMethod <number> Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database.
-v, --verbose Print verbose output
-g, --debug Print debug output
-y, --skipPrompt Skip read key for continous test, default is not skip

View File

@ -0,0 +1,28 @@
##
######## example-requirements.txt #######
##
####### Requirements without Version Specifiers ######
requests
multipledispatch
#beautifulsoup4
##
####### Requirements with Version Specifiers ######
## See https://www.python.org/dev/peps/pep-0440/#version-specifiers
#docopt == 0.6.1 # Version Matching. Must be version 0.6.1
#keyring >= 4.1.1 # Minimum version 4.1.1
#coverage != 3.5 # Version Exclusion. Anything except version 3.5
#Mopidy-Dirble ~= 1.1 # Compatible release. Same as >= 1.1, == 1.*
##
####### Refer to other requirements files ######
#-r other-requirements.txt
##
##
####### A particular file ######
#./downloads/numpy-1.9.2-cp34-none-win32.whl
#http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl
##
####### Additional Requirements without Version Specifiers ######
## Same as 1st section, just here to show that you can put things in any order.
#rejected
#green
##

View File

@ -0,0 +1,797 @@
#!/usr/bin/python3
# * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
# *
# * This program is free software: you can use, redistribute, and/or modify
# * it under the terms of the GNU Affero General Public License, version 3
# * or later ("AGPL"), as published by the Free Software Foundation.
# *
# * This program is distributed in the hope that it will be useful, but WITHOUT
# * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# * FITNESS FOR A PARTICULAR PURPOSE.
# *
# * You should have received a copy of the GNU Affero General Public License
# * along with this program. If not, see <http://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
import sys
import getopt
import requests
import json
import random
import time
import datetime
from multiprocessing import Manager, Pool, Lock
from multipledispatch import dispatch
from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED
@dispatch(str, str)
def v_print(msg: str, arg: str):
if verbose:
print(msg % arg)
@dispatch(str, str, str)
def v_print(msg: str, arg1: str, arg2: str):
if verbose:
print(msg % (arg1, arg2))
@dispatch(str, str, str, str)
def v_print(msg: str, arg1: str, arg2: str, arg3: str):
if verbose:
print(msg % (arg1, arg2, arg3))
@dispatch(str, str, str, str, str)
def v_print(msg: str, arg1: str, arg2: str, arg3: str, arg4: str):
if verbose:
print(msg % (arg1, arg2, arg3, arg4))
@dispatch(str, int)
def v_print(msg: str, arg: int):
if verbose:
print(msg % int(arg))
@dispatch(str, int, str)
def v_print(msg: str, arg1: int, arg2: str):
if verbose:
print(msg % (int(arg1), str(arg2)))
@dispatch(str, str, int)
def v_print(msg: str, arg1: str, arg2: int):
if verbose:
print(msg % (arg1, int(arg2)))
@dispatch(str, int, int)
def v_print(msg: str, arg1: int, arg2: int):
if verbose:
print(msg % (int(arg1), int(arg2)))
@dispatch(str, int, int, str)
def v_print(msg: str, arg1: int, arg2: int, arg3: str):
if verbose:
print(msg % (int(arg1), int(arg2), str(arg3)))
@dispatch(str, int, int, int)
def v_print(msg: str, arg1: int, arg2: int, arg3: int):
if verbose:
print(msg % (int(arg1), int(arg2), int(arg3)))
@dispatch(str, int, int, int, int)
def v_print(msg: str, arg1: int, arg2: int, arg3: int, arg4: int):
if verbose:
print(msg % (int(arg1), int(arg2), int(arg3), int(arg4)))
def restful_execute(host: str, port: int, user: str, password: str, cmd: str):
url = "http://%s:%d/rest/sql" % (host, restPort)
v_print("restful_execute - cmd: %s", cmd)
resp = requests.post(url, cmd, auth=(user, password))
v_print("resp status: %d", resp.status_code)
if debug:
v_print(
"resp text: %s",
json.dumps(
resp.json(),
sort_keys=True,
indent=2))
else:
print("resp: %s" % json.dumps(resp.json()))
def query_func(process: int, thread: int, cmd: str):
v_print("%d process %d thread cmd: %s", process, thread, cmd)
if oneMoreHost != "NotSupported" and random.randint(
0, 1) == 1:
v_print("%s", "Send to second host")
if native:
cursor2.execute(cmd)
else:
restful_execute(
oneMoreHost, port, user, password, cmd)
else:
v_print("%s%s%s", "Send ", cmd, " to the host")
if native:
pass
# cursor.execute(cmd)
else:
restful_execute(
host, port, user, password, cmd)
def query_data_process(cmd: str):
# establish connection if native
if native:
v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir)
try:
conn = taos.connect(
host=host,
user=user,
password=password,
config=configDir)
v_print("conn: %s", str(conn.__class__))
except Exception as e:
print("Error: %s" % e.args[0])
sys.exit(1)
try:
cursor = conn.cursor()
v_print("cursor:%d %s", id(cursor), str(cursor.__class__))
except Exception as e:
print("Error: %s" % e.args[0])
conn.close()
sys.exit(1)
if native:
try:
cursor.execute(cmd)
cols = cursor.description
data = cursor.fetchall()
for col in data:
print(col)
except Exception as e:
conn.close()
print("Error: %s" % e.args[0])
sys.exit(1)
else:
restful_execute(
host,
port,
user,
password,
cmd)
if native:
cursor.close()
conn.close()
def create_stb():
for i in range(0, numOfStb):
if native:
cursor.execute(
"CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" %
(stbName, i))
else:
restful_execute(
host,
port,
user,
password,
"CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" %
(stbName, i)
)
def use_database():
if native:
cursor.execute("USE %s" % current_db)
else:
restful_execute(host, port, user, password, "USE %s" % current_db)
def create_databases():
for i in range(0, numOfDb):
v_print("will create database db%d", int(i))
if native:
cursor.execute(
"CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i))
else:
restful_execute(
host,
port,
user,
password,
"CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i))
def drop_tables():
# TODO
v_print("TODO: drop tables total %d", numOfTb)
pass
def drop_stable():
# TODO
v_print("TODO: drop stables total %d", numOfStb)
pass
def drop_databases():
v_print("drop databases total %d", numOfDb)
# drop exist databases first
for i in range(0, numOfDb):
v_print("will drop database db%d", int(i))
if native:
cursor.execute(
"DROP DATABASE IF EXISTS %s%d" %
(dbName, i))
else:
restful_execute(
host,
port,
user,
password,
"DROP DATABASE IF EXISTS %s%d" %
(dbName, i))
def insert_func(process: int, thread: int):
v_print("%d process %d thread, insert_func ", process, thread)
# generate uuid
uuid_int = random.randint(0, numOfTb + 1)
uuid = "%s" % uuid_int
v_print("uuid is: %s", uuid)
# establish connection if native
if native:
v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir)
try:
conn = taos.connect(
host=host,
user=user,
password=password,
config=configDir)
v_print("conn: %s", str(conn.__class__))
except Exception as e:
print("Error: %s" % e.args[0])
sys.exit(1)
try:
cursor = conn.cursor()
v_print("cursor:%d %s", id(cursor), str(cursor.__class__))
except Exception as e:
print("Error: %s" % e.args[0])
conn.close()
sys.exit(1)
v_print("numOfRec %d:", numOfRec)
row = 0
while row < numOfRec:
v_print("row: %d", row)
sqlCmd = ['INSERT INTO ']
try:
sqlCmd.append(
"%s.%s%d " % (current_db, tbName, thread))
if (numOfStb > 0 and autosubtable):
sqlCmd.append("USING %s.%s%d TAGS('%s') " %
(current_db, stbName, numOfStb - 1, uuid))
start_time = datetime.datetime(
2021, 1, 25) + datetime.timedelta(seconds=row)
sqlCmd.append("VALUES ")
for batchIter in range(0, batch):
sqlCmd.append("('%s', %f) " %
(
start_time +
datetime.timedelta(
milliseconds=batchIter),
random.random()))
row = row + 1
if row >= numOfRec:
v_print("BREAK, row: %d numOfRec:%d", row, numOfRec)
break
except Exception as e:
print("Error: %s" % e.args[0])
cmd = ' '.join(sqlCmd)
if measure:
exec_start_time = datetime.datetime.now()
if native:
affectedRows = cursor.execute(cmd)
else:
restful_execute(
host, port, user, password, cmd)
if measure:
exec_end_time = datetime.datetime.now()
exec_delta = exec_end_time - exec_start_time
v_print(
"consume %d microseconds",
exec_delta.microseconds)
v_print("cmd: %s, length:%d", cmd, len(cmd))
if native:
cursor.close()
conn.close()
def create_tb_using_stb():
# TODO:
pass
def create_tb():
v_print("create_tb() numOfTb: %d", numOfTb)
for i in range(0, numOfDb):
if native:
cursor.execute("USE %s%d" % (dbName, i))
else:
restful_execute(
host, port, user, password, "USE %s%d" %
(dbName, i))
for j in range(0, numOfTb):
if native:
cursor.execute(
"CREATE TABLE %s%d (ts timestamp, value float)" %
(tbName, j))
else:
restful_execute(
host,
port,
user,
password,
"CREATE TABLE %s%d (ts timestamp, value float)" %
(tbName, j))
def insert_data_process(lock, i: int, begin: int, end: int):
lock.acquire()
tasks = end - begin
v_print("insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks)
if (threads < (end - begin)):
for j in range(begin, end, threads):
with ThreadPoolExecutor(max_workers=threads) as executor:
k = end if ((j + threads) > end) else (j + threads)
workers = [
executor.submit(
insert_func,
i,
n) for n in range(
j,
k)]
wait(workers, return_when=ALL_COMPLETED)
else:
with ThreadPoolExecutor(max_workers=threads) as executor:
workers = [
executor.submit(
insert_func,
i,
j) for j in range(
begin,
end)]
wait(workers, return_when=ALL_COMPLETED)
lock.release()
def query_db(i):
if native:
cursor.execute("USE %s%d" % (dbName, i))
else:
restful_execute(
host, port, user, password, "USE %s%d" %
(dbName, i))
for j in range(0, numOfTb):
if native:
cursor.execute(
"SELECT COUNT(*) FROM %s%d" % (tbName, j))
else:
restful_execute(
host, port, user, password, "SELECT COUNT(*) FROM %s%d" %
(tbName, j))
def printConfig():
print("###################################################################")
print("# Use native interface: %s" % native)
print("# Server IP: %s" % host)
if native:
print("# Server port: %s" % port)
else:
print("# Server port: %s" % restPort)
print("# Configuration Dir: %s" % configDir)
print("# User: %s" % user)
print("# Password: %s" % password)
print("# Number of Columns per record: %s" % colsPerRecord)
print("# Number of Threads: %s" % threads)
print("# Number of Processes: %s" % processes)
print("# Number of Tables: %s" % numOfTb)
print("# Number of records per Table: %s" % numOfRec)
print("# Records/Request: %s" % batch)
print("# Database name: %s" % dbName)
print("# Replica: %s" % replica)
print("# Use STable: %s" % useStable)
print("# Table prefix: %s" % tbName)
if useStable:
print("# STable prefix: %s" % stbName)
print("# Data order: %s" % outOfOrder)
print("# Data out of order rate: %s" % rateOOOO)
print("# Delete method: %s" % deleteMethod)
print("# Query command: %s" % queryCmd)
print("# Insert Only: %s" % insertOnly)
print("# Verbose output %s" % verbose)
print("# Test time: %s" %
datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("###################################################################")
if __name__ == "__main__":
native = False
verbose = False
debug = False
measure = True
dropDbOnly = False
colsPerRecord = 3
numOfDb = 1
dbName = "test"
replica = 1
batch = 1
numOfTb = 1
tbName = "tb"
useStable = False
numOfStb = 0
stbName = "stb"
numOfRec = 10
ieration = 1
host = "127.0.0.1"
configDir = "/etc/taos"
oneMoreHost = "NotSupported"
port = 6030
restPort = 6041
user = "root"
defaultPass = "taosdata"
processes = 1
threads = 1
insertOnly = False
autosubtable = False
queryCmd = "NO"
outOfOrder = 0
rateOOOO = 0
deleteMethod = 0
skipPrompt = False
try:
opts, args = getopt.gnu_getopt(sys.argv[1:],
'Nh:p:u:P:d:a:m:Ms:Q:T:C:r:l:t:n:c:xOR:D:vgyH',
[
'native', 'host', 'port', 'user', 'password', 'dbname', 'replica', 'tbname',
'stable', 'stbname', 'query', 'threads', 'processes',
'recPerReq', 'colsPerRecord', 'numOfTb', 'numOfRec', 'config',
'insertOnly', 'outOfOrder', 'rateOOOO', 'deleteMethod',
'verbose', 'debug', 'skipPrompt', 'help'
])
except getopt.GetoptError as err:
print('ERROR:', err)
print('Try `taosdemo.py --help` for more options.')
sys.exit(1)
if bool(opts) is False:
print('Try `taosdemo.py --help` for more options.')
sys.exit(1)
for key, value in opts:
if key in ['-H', '--help']:
print('')
print(
'taosdemo.py for TDengine')
print('')
print('Author: Shuduo Sang <sangshuduo@gmail.com>')
print('')
print('\t-H, --help Show usage.')
print('')
print('\t-N, --native flag, Use native interface if set. Default is using RESTful interface.')
print('\t-h, --host <hostname> host, The host to connect to TDengine. Default is localhost.')
print('\t-p, --port <port> port, The TCP/IP port number to use for the connection. Default is 0.')
print('\t-u, --user <username> user, The user name to use when connecting to the server. Default is \'root\'.')
print('\t-P, --password <password> password, The password to use when connecting to the server. Default is \'taosdata\'.')
print('\t-l, --colsPerRec <number> num_of_columns_per_record, The number of columns per record. Default is 3.')
print(
'\t-d, --dbname <dbname> database, Destination database. Default is \'test\'.')
print('\t-a, --replica <replications> replica, Set the replica parameters of the database, Default 1, min: 1, max: 5.')
print(
'\t-m, --tbname <table prefix> table_prefix, Table prefix name. Default is \'t\'.')
print(
'\t-M, --stable flag, Use super table. Default is no')
print(
'\t-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is \'st\'')
print('\t-Q, --query [NO|EACHTB|command] query, Execute query command. set \'EACHTB\' means select * from each table')
print(
'\t-T, --threads <number> num_of_threads, The number of threads. Default is 1.')
print(
'\t-C, --processes <number> num_of_processes, The number of threads. Default is 1.')
print('\t-r, --batch <number> num_of_records_per_req, The number of records per request. Default is 1000.')
print(
'\t-t, --numOfTb <number> num_of_tables, The number of tables. Default is 1.')
print('\t-n, --numOfRec <number> num_of_records_per_table, The number of records per table. Default is 1.')
print('\t-c, --config <path> config_directory, Configuration directory. Default is \'/etc/taos/\'.')
print('\t-x, --inserOnly flag, Insert only flag.')
print('\t-O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order.')
print('\t-R, --rateOOOO <number> rate, Out of order data\'s rate--if order=1 Default 10, min: 0, max: 50.')
print('\t-D, --deleteMethod <number> Delete data methods 0: don\'t delete, 1: delete by table, 2: delete by stable, 3: delete by database.')
print('\t-v, --verbose Print verbose output')
print('\t-g, --debug Print debug output')
print(
'\t-y, --skipPrompt Skip read key for continous test, default is not skip')
print('')
sys.exit(0)
if key in ['-N', '--native']:
try:
import taos
except Exception as e:
print("Error: %s" % e.args[0])
sys.exit(1)
native = True
if key in ['-h', '--host']:
host = value
if key in ['-p', '--port']:
port = int(value)
if key in ['-u', '--user']:
user = value
if key in ['-P', '--password']:
password = value
else:
password = defaultPass
if key in ['-d', '--dbname']:
dbName = value
if key in ['-a', '--replica']:
replica = int(value)
if replica < 1:
print("FATAL: number of replica need > 0")
sys.exit(1)
if key in ['-m', '--tbname']:
tbName = value
if key in ['-M', '--stable']:
useStable = True
numOfStb = 1
if key in ['-s', '--stbname']:
stbName = value
if key in ['-Q', '--query']:
queryCmd = str(value)
if key in ['-T', '--threads']:
threads = int(value)
if threads < 1:
print("FATAL: number of threads must be larger than 0")
sys.exit(1)
if key in ['-C', '--processes']:
processes = int(value)
if processes < 1:
print("FATAL: number of processes must be larger than 0")
sys.exit(1)
if key in ['-r', '--batch']:
batch = int(value)
if key in ['-l', '--colsPerRec']:
colsPerRec = int(value)
if key in ['-t', '--numOfTb']:
numOfTb = int(value)
v_print("numOfTb is %d", numOfTb)
if key in ['-n', '--numOfRec']:
numOfRec = int(value)
v_print("numOfRec is %d", numOfRec)
if numOfRec < 1:
print("FATAL: number of records must be larger than 0")
sys.exit(1)
if key in ['-c', '--config']:
configDir = value
v_print("config dir: %s", configDir)
if key in ['-x', '--insertOnly']:
insertOnly = True
v_print("insert only: %d", insertOnly)
if key in ['-O', '--outOfOrder']:
outOfOrder = int(value)
v_print("out of order is %d", outOfOrder)
if key in ['-R', '--rateOOOO']:
rateOOOO = int(value)
v_print("the rate of out of order is %d", rateOOOO)
if key in ['-D', '--deleteMethod']:
deleteMethod = int(value)
if (deleteMethod < 0) or (deleteMethod > 3):
print(
"inputed delete method is %d, valid value is 0~3, set to default 0" %
deleteMethod)
deleteMethod = 0
v_print("the delete method is %d", deleteMethod)
if key in ['-v', '--verbose']:
verbose = True
if key in ['-g', '--debug']:
debug = True
if key in ['-y', '--skipPrompt']:
skipPrompt = True
if verbose:
printConfig()
if not skipPrompt:
input("Press any key to continue..")
# establish connection first if native
if native:
v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir)
try:
conn = taos.connect(
host=host,
user=user,
password=password,
config=configDir)
v_print("conn: %s", str(conn.__class__))
except Exception as e:
print("Error: %s" % e.args[0])
sys.exit(1)
try:
cursor = conn.cursor()
v_print("cursor:%d %s", id(cursor), str(cursor.__class__))
except Exception as e:
print("Error: %s" % e.args[0])
conn.close()
sys.exit(1)
# drop data only if delete method be set
if deleteMethod > 0:
if deleteMethod == 1:
drop_tables()
print("Drop tables done.")
elif deleteMethod == 2:
drop_stables()
print("Drop super tables done.")
elif deleteMethod == 3:
drop_databases()
print("Drop Database done.")
sys.exit(0)
# create databases
drop_databases()
create_databases()
# use last database
current_db = "%s%d" % (dbName, (numOfDb - 1))
use_database()
if measure:
start_time_begin = time.time()
if numOfStb > 0:
create_stb()
if (autosubtable == False):
create_tb_using_stb()
else:
create_tb()
if measure:
end_time = time.time()
print(
"Total time consumed {} seconds for create table.".format(
(end_time - start_time_begin)))
if native:
cursor.close()
conn.close()
# start insert data
if measure:
start_time = time.time()
manager = Manager()
lock = manager.Lock()
pool = Pool(processes)
begin = 0
end = 0
quotient = numOfTb // processes
if quotient < 1:
processes = numOfTb
quotient = 1
remainder = numOfTb % processes
v_print(
"num of tables: %d, quotient: %d, remainder: %d",
numOfTb,
quotient,
remainder)
for i in range(processes):
begin = end
if i < remainder:
end = begin + quotient + 1
else:
end = begin + quotient
pool.apply_async(insert_data_process, args=(lock, i, begin, end,))
pool.close()
pool.join()
time.sleep(1)
if measure:
end_time = time.time()
print(
"Total time consumed {} seconds for insert data.".format(
(end_time - start_time)))
# query data
if queryCmd != "NO":
print("queryCmd: %s" % queryCmd)
query_data_process(queryCmd)
if measure:
end_time = time.time()
print(
"Total time consumed {} seconds.".format(
(end_time - start_time_begin)))
print("done")

View File

@ -0,0 +1,82 @@
#!/bin/bash
# This is the script for us to try to cause the TDengine server or client to crash
#
# PREPARATION
#
# 1. Build an compile the TDengine source code that comes with this script, in the same directory tree
# 2. Please follow the direction in our README.md, and build TDengine in the build/ directory
# 3. Adjust the configuration file if needed under build/test/cfg/taos.cfg
# 4. Run the TDengine server instance: cd build; ./build/bin/taosd -c test/cfg
# 5. Make sure you have a working Python3 environment: run /usr/bin/python3 --version, and you should get 3.6 or above
# 6. Make sure you have the proper Python packages: # sudo apt install python3-setuptools python3-pip python3-distutils
#
# RUNNING THIS SCRIPT
#
# This script assumes the source code directory is intact, and that the binaries has been built in the
# build/ directory, as such, will will load the Python libraries in the directory tree, and also load
# the TDengine client shared library (so) file, in the build/directory, as evidenced in the env
# variables below.
#
# Running the script is simple, no parameter is needed (for now, but will change in the future).
#
# Happy Crashing...
# Due to the heavy path name assumptions/usage, let us require that the user be in the current directory
EXEC_DIR=`dirname "$0"`
if [[ $EXEC_DIR != "." ]]
then
echo "ERROR: Please execute `basename "$0"` in its own directory (for now anyway, pardon the dust)"
exit -1
fi
CURR_DIR=`pwd`
IN_TDINTERNAL="community"
if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then
TAOS_DIR=$CURR_DIR/../../..
TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1`
LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6,7|rev`/lib
else
TAOS_DIR=$CURR_DIR/../..
TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1`
LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib
fi
# Now getting ready to execute Python
# The following is the default of our standard dev env (Ubuntu 20.04), modify/adjust at your own risk
PYTHON_EXEC=python3.8
# First we need to set up a path for Python to find our own TAOS modules, so that "import" can work.
export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3:$(pwd)
# Then let us set up the library path so that our compiled SO file can be loaded by Python
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR
# Now we are all let, and let's see if we can find a crash. Note we pass all params
CONCURRENT_INQUIRY=concurrent_inquiry.py
if [[ $1 == '--valgrind' ]]; then
shift
export PYTHONMALLOC=malloc
VALGRIND_OUT=valgrind.out
VALGRIND_ERR=valgrind.err
# How to generate valgrind suppression file: https://stackoverflow.com/questions/17159578/generating-suppressions-for-memory-leaks
# valgrind --leak-check=full --gen-suppressions=all --log-fd=9 python3.8 ./concurrent_inquiry.py $@ 9>>memcheck.log
echo Executing under VALGRIND, with STDOUT/ERR going to $VALGRIND_OUT and $VALGRIND_ERR, please watch them from a different terminal.
valgrind \
--leak-check=yes \
--suppressions=crash_gen/valgrind_taos.supp \
$PYTHON_EXEC \
$CONCURRENT_INQUIRY $@ > $VALGRIND_OUT 2> $VALGRIND_ERR
elif [[ $1 == '--helgrind' ]]; then
shift
HELGRIND_OUT=helgrind.out
HELGRIND_ERR=helgrind.err
valgrind \
--tool=helgrind \
$PYTHON_EXEC \
$CONCURRENT_INQUIRY $@ > $HELGRIND_OUT 2> $HELGRIND_ERR
else
$PYTHON_EXEC $CONCURRENT_INQUIRY $@
fi

View File

@ -7,15 +7,10 @@ python3 ./test.py -f update/append_commit_data.py
python3 ./test.py -f update/append_commit_last-0.py python3 ./test.py -f update/append_commit_last-0.py
python3 ./test.py -f update/append_commit_last.py python3 ./test.py -f update/append_commit_last.py
python3 ./test.py -f update/merge_commit_data.py python3 ./test.py -f update/merge_commit_data.py
python3 ./test.py -f update/merge_commit_data-0.py
python3 ./test.py -f update/merge_commit_data2.py python3 ./test.py -f update/merge_commit_data2.py
python3 ./test.py -f update/merge_commit_data2_update0.py python3 ./test.py -f update/merge_commit_data2_update0.py
python3 ./test.py -f update/merge_commit_last-0.py python3 ./test.py -f update/merge_commit_last-0.py
python3 ./test.py -f update/merge_commit_last.py python3 ./test.py -f update/merge_commit_last.py
python3 ./test.py -f update/bug_td2279.py python3 ./test.py -f update/bug_td2279.py
# wal
python3 ./test.py -f wal/addOldWalTest.py
# function
python3 ./test.py -f functions/all_null_value.py

View File

@ -70,26 +70,7 @@ python3 testCompress.py
python3 testNoCompress.py python3 testNoCompress.py
python3 testMinTablesPerVnode.py python3 testMinTablesPerVnode.py
# functions
python3 ./test.py -f functions/function_avg.py -r 1
python3 ./test.py -f functions/function_bottom.py -r 1
python3 ./test.py -f functions/function_count.py -r 1
python3 ./test.py -f functions/function_diff.py -r 1
python3 ./test.py -f functions/function_first.py -r 1
python3 ./test.py -f functions/function_last.py -r 1
python3 ./test.py -f functions/function_last_row.py -r 1
python3 ./test.py -f functions/function_leastsquares.py -r 1
python3 ./test.py -f functions/function_max.py -r 1
python3 ./test.py -f functions/function_min.py -r 1
python3 ./test.py -f functions/function_operations.py -r 1
python3 ./test.py -f functions/function_percentile.py -r 1
python3 ./test.py -f functions/function_spread.py -r 1
python3 ./test.py -f functions/function_stddev.py -r 1
python3 ./test.py -f functions/function_sum.py -r 1
python3 ./test.py -f functions/function_top.py -r 1
python3 ./test.py -f functions/function_twa.py -r 1
python3 ./test.py -f functions/function_twa_test2.py
python3 ./test.py -f functions/function_stddev_td2555.py
python3 queryCount.py python3 queryCount.py
python3 ./test.py -f query/queryGroupbyWithInterval.py python3 ./test.py -f query/queryGroupbyWithInterval.py
python3 client/twoClients.py python3 client/twoClients.py

26
tests/pytest/pytest_4.sh Executable file
View File

@ -0,0 +1,26 @@
python3 ./test.py -f update/merge_commit_data-0.py
# wal
python3 ./test.py -f wal/addOldWalTest.py
# function
python3 ./test.py -f functions/all_null_value.py
# functions
python3 ./test.py -f functions/function_avg.py -r 1
python3 ./test.py -f functions/function_bottom.py -r 1
python3 ./test.py -f functions/function_count.py -r 1
python3 ./test.py -f functions/function_diff.py -r 1
python3 ./test.py -f functions/function_first.py -r 1
python3 ./test.py -f functions/function_last.py -r 1
python3 ./test.py -f functions/function_last_row.py -r 1
python3 ./test.py -f functions/function_leastsquares.py -r 1
python3 ./test.py -f functions/function_max.py -r 1
python3 ./test.py -f functions/function_min.py -r 1
python3 ./test.py -f functions/function_operations.py -r 1
python3 ./test.py -f functions/function_percentile.py -r 1
python3 ./test.py -f functions/function_spread.py -r 1
python3 ./test.py -f functions/function_stddev.py -r 1
python3 ./test.py -f functions/function_sum.py -r 1
python3 ./test.py -f functions/function_top.py -r 1
python3 ./test.py -f functions/function_twa.py -r 1
python3 ./test.py -f functions/function_twa_test2.py
python3 ./test.py -f functions/function_stddev_td2555.pyhao

View File

@ -1,14 +1,3 @@
./test.sh -f unique/dnode/alternativeRole.sim
./test.sh -f unique/dnode/balance1.sim
./test.sh -f unique/dnode/balance2.sim
./test.sh -f unique/dnode/balance3.sim
./test.sh -f unique/dnode/balancex.sim
./test.sh -f unique/dnode/offline1.sim
./test.sh -f unique/dnode/offline2.sim
./test.sh -f unique/dnode/reason.sim
./test.sh -f unique/dnode/remove1.sim
./test.sh -f unique/dnode/remove2.sim
./test.sh -f unique/dnode/vnode_clean.sim
./test.sh -f unique/http/admin.sim ./test.sh -f unique/http/admin.sim
./test.sh -f unique/http/opentsdb.sim ./test.sh -f unique/http/opentsdb.sim

View File

@ -1,3 +1,11 @@
./test.sh -f unique/dnode/alternativeRole.sim
./test.sh -f unique/dnode/balance1.sim
./test.sh -f unique/dnode/balance2.sim
./test.sh -f unique/dnode/balance3.sim
./test.sh -f unique/dnode/balancex.sim
./test.sh -f unique/dnode/offline1.sim
./test.sh -f unique/dnode/offline2.sim
./test.sh -f general/stream/metrics_del.sim ./test.sh -f general/stream/metrics_del.sim
./test.sh -f general/stream/metrics_replica1_vnoden.sim ./test.sh -f general/stream/metrics_replica1_vnoden.sim
./test.sh -f general/stream/restart_stream.sim ./test.sh -f general/stream/restart_stream.sim

View File

@ -1,3 +1,8 @@
./test.sh -f unique/dnode/reason.sim
./test.sh -f unique/dnode/remove1.sim
./test.sh -f unique/dnode/remove2.sim
./test.sh -f unique/dnode/vnode_clean.sim
./test.sh -f unique/db/commit.sim ./test.sh -f unique/db/commit.sim
./test.sh -f unique/db/delete.sim ./test.sh -f unique/db/delete.sim
./test.sh -f unique/db/delete_part.sim ./test.sh -f unique/db/delete_part.sim

View File

@ -261,6 +261,9 @@ if [ "$2" != "sim" ]; then
elif [ "$1" == "p3" ]; then elif [ "$1" == "p3" ]; then
echo "### run Python_3 test ###" echo "### run Python_3 test ###"
runPyCaseOneByOnefq pytest_3.sh runPyCaseOneByOnefq pytest_3.sh
elif [ "$1" == "p4" ]; then
echo "### run Python_4 test ###"
runPyCaseOneByOnefq pytest_4.sh
elif [ "$1" == "b2" ] || [ "$1" == "b3" ]; then elif [ "$1" == "b2" ] || [ "$1" == "b3" ]; then
exit $(($totalFailed + $totalPyFailed)) exit $(($totalFailed + $totalPyFailed))
elif [ "$1" == "smoke" ] || [ -z "$1" ]; then elif [ "$1" == "smoke" ] || [ -z "$1" ]; then