change
This commit is contained in:
parent
55735e8d84
commit
9d773e1234
|
@ -137,10 +137,57 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException;
|
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
|
||||||
|
if (isClosed())
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||||
|
|
||||||
|
switch (resultSetType) {
|
||||||
|
case ResultSet.TYPE_FORWARD_ONLY:
|
||||||
|
break;
|
||||||
|
case ResultSet.TYPE_SCROLL_INSENSITIVE:
|
||||||
|
case ResultSet.TYPE_SCROLL_SENSITIVE:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
|
default:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (resultSetConcurrency) {
|
||||||
|
case ResultSet.CONCUR_READ_ONLY:
|
||||||
|
break;
|
||||||
|
case ResultSet.CONCUR_UPDATABLE:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
|
default:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createStatement();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException;
|
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
|
||||||
|
if (isClosed())
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||||
|
|
||||||
|
switch (resultSetType) {
|
||||||
|
case ResultSet.TYPE_FORWARD_ONLY:
|
||||||
|
break;
|
||||||
|
case ResultSet.TYPE_SCROLL_INSENSITIVE:
|
||||||
|
case ResultSet.TYPE_SCROLL_SENSITIVE:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
|
default:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (resultSetConcurrency) {
|
||||||
|
case ResultSet.CONCUR_READ_ONLY:
|
||||||
|
break;
|
||||||
|
case ResultSet.CONCUR_UPDATABLE:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
|
default:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
|
}
|
||||||
|
return prepareStatement(sql);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
|
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
|
||||||
|
@ -170,6 +217,15 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
|
||||||
public void setHoldability(int holdability) throws SQLException {
|
public void setHoldability(int holdability) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||||
|
|
||||||
|
switch (holdability) {
|
||||||
|
case ResultSet.HOLD_CURSORS_OVER_COMMIT:
|
||||||
|
break;
|
||||||
|
case ResultSet.CLOSE_CURSORS_AT_COMMIT:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
|
default:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
|
}
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,10 +270,38 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException;
|
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
|
||||||
|
if (isClosed())
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||||
|
|
||||||
|
switch (resultSetHoldability) {
|
||||||
|
case ResultSet.HOLD_CURSORS_OVER_COMMIT:
|
||||||
|
break;
|
||||||
|
case ResultSet.CLOSE_CURSORS_AT_COMMIT:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
|
default:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createStatement(resultSetType, resultSetConcurrency);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract 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 (isClosed())
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||||
|
|
||||||
|
switch (resultSetHoldability) {
|
||||||
|
case ResultSet.HOLD_CURSORS_OVER_COMMIT:
|
||||||
|
break;
|
||||||
|
case ResultSet.CLOSE_CURSORS_AT_COMMIT:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
|
default:
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
@ -231,14 +315,14 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
|
||||||
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
|
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||||
|
|
||||||
switch (autoGeneratedKeys) {
|
switch (autoGeneratedKeys) {
|
||||||
case Statement.RETURN_GENERATED_KEYS:
|
case Statement.RETURN_GENERATED_KEYS:
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
case Statement.NO_GENERATED_KEYS:
|
case Statement.NO_GENERATED_KEYS:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||||
return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,6 +23,14 @@ public class TSDBConnection extends AbstractConnection {
|
||||||
private TSDBDatabaseMetaData databaseMetaData;
|
private TSDBDatabaseMetaData databaseMetaData;
|
||||||
private boolean batchFetch;
|
private boolean batchFetch;
|
||||||
|
|
||||||
|
public Boolean getBatchFetch() {
|
||||||
|
return this.batchFetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBatchFetch(Boolean batchFetch) {
|
||||||
|
this.batchFetch = batchFetch;
|
||||||
|
}
|
||||||
|
|
||||||
public TSDBConnection(Properties info, TSDBDatabaseMetaData meta) throws SQLException {
|
public TSDBConnection(Properties info, TSDBDatabaseMetaData meta) throws SQLException {
|
||||||
this.databaseMetaData = meta;
|
this.databaseMetaData = meta;
|
||||||
connect(info.getProperty(TSDBDriver.PROPERTY_KEY_HOST),
|
connect(info.getProperty(TSDBDriver.PROPERTY_KEY_HOST),
|
||||||
|
@ -104,47 +112,4 @@ public class TSDBConnection extends AbstractConnection {
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
|
|
||||||
throws SQLException {
|
|
||||||
// This method is implemented in the current way to support Spark
|
|
||||||
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {
|
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
|
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.prepareStatement(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getBatchFetch() {
|
|
||||||
return this.batchFetch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBatchFetch(Boolean batchFetch) {
|
|
||||||
this.batchFetch = batchFetch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
|
|
||||||
throws SQLException {
|
|
||||||
if (isClosed()) {
|
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
|
||||||
}
|
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
|
|
||||||
int resultSetHoldability) throws SQLException {
|
|
||||||
if (isClosed()) {
|
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
|
||||||
}
|
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean isValid(int timeout) throws SQLException {
|
|
||||||
// return !this.isClosed();
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import javax.management.OperationsException;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -15,174 +16,265 @@ public class TSDBConnectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnection() {
|
public void getConnection() {
|
||||||
|
// already test in beforeClass method
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createStatement() {
|
public void createStatement() {
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
ResultSet rs = stmt.executeQuery("select server_status()");
|
||||||
|
rs.next();
|
||||||
|
int status = rs.getInt("server_status()");
|
||||||
|
Assert.assertEquals(1, status);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subscribe() {
|
public void subscribe() {
|
||||||
|
try {
|
||||||
|
TSDBConnection unwrap = conn.unwrap(TSDBConnection.class);
|
||||||
|
TSDBSubscribe subscribe = unwrap.subscribe("topic1", "select server_status()", false);
|
||||||
|
TSDBResultSet rs = subscribe.consume();
|
||||||
|
rs.next();
|
||||||
|
int status = rs.getInt("server_status()");
|
||||||
|
Assert.assertEquals(1, status);
|
||||||
|
} catch (SQLException | OperationsException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void prepareStatement() {
|
public void prepareStatement() throws SQLException {
|
||||||
|
PreparedStatement pstmt = conn.prepareStatement("select server_status()");
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
rs.next();
|
||||||
|
int status = rs.getInt("server_status()");
|
||||||
|
Assert.assertEquals(1, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
public void prepareCall() throws SQLException {
|
||||||
|
conn.prepareCall("select server_status()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void prepareCall() {
|
public void nativeSQL() throws SQLException {
|
||||||
|
String nativeSQL = conn.nativeSQL("select * from log.log");
|
||||||
|
Assert.assertEquals("select * from log.log", nativeSQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nativeSQL() {
|
public void setAutoCommit() throws SQLException {
|
||||||
|
conn.setAutoCommit(true);
|
||||||
|
conn.setAutoCommit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setAutoCommit() {
|
public void getAutoCommit() throws SQLException {
|
||||||
|
Assert.assertTrue(conn.getAutoCommit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAutoCommit() {
|
public void commit() throws SQLException {
|
||||||
|
conn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void commit() {
|
public void rollback() throws SQLException {
|
||||||
}
|
conn.rollback();
|
||||||
|
|
||||||
@Test
|
|
||||||
public void rollback() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void close() {
|
public void close() {
|
||||||
|
// connection will close in afterClass method
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isClosed() {
|
public void isClosed() throws SQLException {
|
||||||
|
Assert.assertFalse(conn.isClosed());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMetaData() {
|
public void getMetaData() throws SQLException {
|
||||||
|
DatabaseMetaData meta = conn.getMetaData();
|
||||||
|
Assert.assertNotNull(meta);
|
||||||
|
Assert.assertEquals("com.taosdata.jdbc.TSDBDriver", meta.getDriverName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setReadOnly() {
|
public void setReadOnly() throws SQLException {
|
||||||
|
conn.setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isReadOnly() {
|
public void isReadOnly() throws SQLException {
|
||||||
|
Assert.assertTrue(conn.isReadOnly());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setCatalog() {
|
public void setCatalog() throws SQLException {
|
||||||
|
conn.setCatalog("test");
|
||||||
|
Assert.assertEquals("test", conn.getCatalog());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getCatalog() {
|
public void getCatalog() throws SQLException {
|
||||||
|
Assert.assertEquals("log", conn.getCatalog());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
public void setTransactionIsolation() throws SQLException {
|
||||||
|
conn.setTransactionIsolation(Connection.TRANSACTION_NONE);
|
||||||
|
Assert.assertEquals(Connection.TRANSACTION_NONE, conn.getTransactionIsolation());
|
||||||
|
|
||||||
|
conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setTransactionIsolation() {
|
public void getTransactionIsolation() throws SQLException {
|
||||||
|
Assert.assertEquals(Connection.TRANSACTION_NONE, conn.getTransactionIsolation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTransactionIsolation() {
|
public void getWarnings() throws SQLException {
|
||||||
|
Assert.assertNull(conn.getWarnings());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWarnings() {
|
public void clearWarnings() throws SQLException {
|
||||||
|
conn.clearWarnings();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
public void testCreateStatement() throws SQLException {
|
||||||
|
Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||||
|
ResultSet rs = stmt.executeQuery("select server_status()");
|
||||||
|
rs.next();
|
||||||
|
int status = rs.getInt("server_status()");
|
||||||
|
Assert.assertEquals(1, status);
|
||||||
|
|
||||||
|
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
public void testPrepareStatement() throws SQLException {
|
||||||
|
PreparedStatement pstmt = conn.prepareStatement("select server_status()",
|
||||||
|
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
rs.next();
|
||||||
|
int status = rs.getInt("server_status()");
|
||||||
|
Assert.assertEquals(1, status);
|
||||||
|
|
||||||
|
conn.prepareStatement("select server_status", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
public void testPrepareCall() throws SQLException {
|
||||||
|
conn.prepareCall("", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
public void getTypeMap() throws SQLException {
|
||||||
|
conn.getTypeMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
public void setTypeMap() throws SQLException {
|
||||||
|
conn.setTypeMap(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
public void setHoldability() throws SQLException {
|
||||||
|
conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||||
|
Assert.assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, conn.getHoldability());
|
||||||
|
conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clearWarnings() {
|
public void getHoldability() throws SQLException {
|
||||||
|
Assert.assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, conn.getHoldability());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void testCreateStatement() {
|
public void setSavepoint() throws SQLException {
|
||||||
|
conn.setSavepoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void testPrepareStatement() {
|
public void testSetSavepoint() throws SQLException {
|
||||||
|
conn.setSavepoint(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void getBatchFetch() {
|
public void testRollback() throws SQLException {
|
||||||
|
conn.rollback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void setBatchFetch() {
|
public void releaseSavepoint() throws SQLException {
|
||||||
|
conn.releaseSavepoint(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void testPrepareCall() {
|
public void testCreateStatement1() throws SQLException {
|
||||||
|
Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||||
|
ResultSet rs = stmt.executeQuery("select server_status()");
|
||||||
|
rs.next();
|
||||||
|
int status = rs.getInt("server_status()");
|
||||||
|
Assert.assertEquals(1, status);
|
||||||
|
|
||||||
|
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void getTypeMap() {
|
public void testPrepareStatement1() throws SQLException {
|
||||||
|
PreparedStatement pstmt = conn.prepareStatement("select server_status()",
|
||||||
|
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
rs.next();
|
||||||
|
int status = rs.getInt("server_status()");
|
||||||
|
Assert.assertEquals(1, status);
|
||||||
|
|
||||||
|
conn.prepareStatement("select server_status", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void setTypeMap() {
|
public void testPrepareCall1() throws SQLException {
|
||||||
|
conn.prepareCall("", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void setHoldability() {
|
public void testPrepareStatement2() throws SQLException {
|
||||||
|
Assert.assertNotNull("", Statement.NO_GENERATED_KEYS);
|
||||||
|
conn.prepareStatement("", Statement.RETURN_GENERATED_KEYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void getHoldability() {
|
public void testPrepareStatement3() throws SQLException {
|
||||||
|
conn.prepareStatement("", new int[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void setSavepoint() {
|
public void testPrepareStatement4() throws SQLException {
|
||||||
|
conn.prepareStatement("", new String[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void testSetSavepoint() {
|
public void createClob() throws SQLException {
|
||||||
|
conn.createClob();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void testRollback() {
|
public void createBlob() throws SQLException {
|
||||||
|
conn.createBlob();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
public void releaseSavepoint() {
|
public void createNClob() throws SQLException {
|
||||||
}
|
conn.createNClob();
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateStatement1() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPrepareStatement1() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPrepareCall1() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPrepareStatement2() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPrepareStatement3() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPrepareStatement4() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void createClob() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void createBlob() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void createNClob() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = SQLFeatureNotSupportedException.class)
|
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||||
|
@ -190,10 +282,11 @@ public class TSDBConnectionTest {
|
||||||
conn.createSQLXML();
|
conn.createSQLXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLException.class)
|
||||||
public void isValid() throws SQLException {
|
public void isValid() throws SQLException {
|
||||||
Assert.assertTrue(conn.isValid(5));
|
Assert.assertTrue(conn.isValid(10));
|
||||||
conn.isValid(0);
|
Assert.assertTrue(conn.isValid(0));
|
||||||
|
conn.isValid(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -299,7 +392,12 @@ public class TSDBConnectionTest {
|
||||||
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");
|
||||||
conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", properties);
|
conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/log?user=root&password=taosdata", properties);
|
||||||
|
// create test database for test cases
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
stmt.execute("create database if not exists test");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue