Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1314,31 +1314,26 @@ public void testUseSameStatement() throws SQLException {
statement.execute("insert into root.sg1.d1(timestamp,s0,s1) values(1000,1000,1000)");
statement.execute("insert into root.sg1.d0(timestamp,s0,s1) values(10,10,10)");

List<ResultSet> resultSetList = new ArrayList<>();

ResultSet r1 = statement.executeQuery("select * from root.sg1.d0 where time <= 1");
resultSetList.add(r1);

ResultSet r2 = statement.executeQuery("select * from root.sg1.d1 where s0 == 1000");
resultSetList.add(r2);

ResultSet r3 = statement.executeQuery("select * from root.sg1.d0 where s1 == 10");
resultSetList.add(r3);

r1.next();
Assert.assertEquals(r1.getLong(1), 1L);
Assert.assertEquals(r1.getLong(2), 1L);
Assert.assertEquals(r1.getLong(3), 1L);
try (ResultSet r1 = statement.executeQuery("select * from root.sg1.d0 where time <= 1")) {
Assert.assertTrue(r1.next());
Assert.assertEquals(r1.getLong(1), 1L);
Assert.assertEquals(r1.getLong(2), 1L);
Assert.assertEquals(r1.getLong(3), 1L);
}

r2.next();
Assert.assertEquals(r2.getLong(1), 1000L);
Assert.assertEquals(r2.getLong(2), 1000L);
Assert.assertEquals(r2.getLong(3), 1000L);
try (ResultSet r2 = statement.executeQuery("select * from root.sg1.d1 where s0 == 1000")) {
Assert.assertTrue(r2.next());
Assert.assertEquals(r2.getLong(1), 1000L);
Assert.assertEquals(r2.getLong(2), 1000L);
Assert.assertEquals(r2.getLong(3), 1000L);
}

r3.next();
Assert.assertEquals(r3.getLong(1), 10L);
Assert.assertEquals(r3.getLong(2), 10L);
Assert.assertEquals(r3.getLong(3), 10L);
try (ResultSet r3 = statement.executeQuery("select * from root.sg1.d0 where s1 == 10")) {
Assert.assertTrue(r3.next());
Assert.assertEquals(r3.getLong(1), 10L);
Assert.assertEquals(r3.getLong(2), 10L);
Assert.assertEquals(r3.getLong(3), 10L);
}
} finally {
executeQuietly(statement, "DELETE DATABASE root.sg1");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,31 +577,29 @@ public void testUseSameStatement() throws SQLException {
statement.execute("insert into table1(time,device,s0,s1) values(1000,'d1',1000,1000)");
statement.execute("insert into table1(time,device,s0,s1) values(10,'d0',10,10)");

List<ResultSet> resultSetList = new ArrayList<>();

ResultSet r1 = statement.executeQuery("select * from table1 where device='d0' and time <= 1");
resultSetList.add(r1);

ResultSet r2 = statement.executeQuery("select * from table1 where device='d1' and s0 = 1000");
resultSetList.add(r2);

ResultSet r3 = statement.executeQuery("select * from table1 where device='d0' and s1 = 10");
resultSetList.add(r3);

r1.next();
Assert.assertEquals(r1.getLong(1), 1L);
Assert.assertEquals(r1.getLong(3), 1L);
Assert.assertEquals(r1.getLong(4), 1L);
try (ResultSet r1 =
statement.executeQuery("select * from table1 where device='d0' and time <= 1")) {
Assert.assertTrue(r1.next());
Assert.assertEquals(r1.getLong(1), 1L);
Assert.assertEquals(r1.getLong(3), 1L);
Assert.assertEquals(r1.getLong(4), 1L);
}

r2.next();
Assert.assertEquals(r2.getLong(1), 1000L);
Assert.assertEquals(r2.getLong(3), 1000L);
Assert.assertEquals(r2.getLong(4), 1000L);
try (ResultSet r2 =
statement.executeQuery("select * from table1 where device='d1' and s0 = 1000")) {
Assert.assertTrue(r2.next());
Assert.assertEquals(r2.getLong(1), 1000L);
Assert.assertEquals(r2.getLong(3), 1000L);
Assert.assertEquals(r2.getLong(4), 1000L);
}

r3.next();
Assert.assertEquals(r3.getLong(1), 10L);
Assert.assertEquals(r3.getLong(3), 10L);
Assert.assertEquals(r3.getLong(4), 10L);
try (ResultSet r3 =
statement.executeQuery("select * from table1 where device='d0' and s1 = 10")) {
Assert.assertTrue(r3.next());
Assert.assertEquals(r3.getLong(1), 10L);
Assert.assertEquals(r3.getLong(3), 10L);
Assert.assertEquals(r3.getLong(4), 10L);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@
import java.sql.Statement;
import java.sql.Types;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import static org.apache.iotdb.db.it.utils.TestUtils.defaultFormatDataTime;
import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest;
Expand Down Expand Up @@ -453,31 +451,29 @@ public void testUseSameStatement() throws SQLException {
statement.execute(
"CREATE VIEW table1(device STRING TAG, s0 INT64 FIELD, s1 INT64 FIELD) as root.sg1.**");

List<ResultSet> resultSetList = new ArrayList<>();

ResultSet r1 = statement.executeQuery("select * from table1 where device='d0' and time <= 1");
resultSetList.add(r1);

ResultSet r2 = statement.executeQuery("select * from table1 where device='d1' and s0 = 1000");
resultSetList.add(r2);

ResultSet r3 = statement.executeQuery("select * from table1 where device='d0' and s1 = 10");
resultSetList.add(r3);

r1.next();
Assert.assertEquals(r1.getLong(1), 1L);
Assert.assertEquals(r1.getLong(3), 1L);
Assert.assertEquals(r1.getLong(4), 1L);
try (ResultSet r1 =
statement.executeQuery("select * from table1 where device='d0' and time <= 1")) {
Assert.assertTrue(r1.next());
Assert.assertEquals(r1.getLong(1), 1L);
Assert.assertEquals(r1.getLong(3), 1L);
Assert.assertEquals(r1.getLong(4), 1L);
}

r2.next();
Assert.assertEquals(r2.getLong(1), 1000L);
Assert.assertEquals(r2.getLong(3), 1000L);
Assert.assertEquals(r2.getLong(4), 1000L);
try (ResultSet r2 =
statement.executeQuery("select * from table1 where device='d1' and s0 = 1000")) {
Assert.assertTrue(r2.next());
Assert.assertEquals(r2.getLong(1), 1000L);
Assert.assertEquals(r2.getLong(3), 1000L);
Assert.assertEquals(r2.getLong(4), 1000L);
}

r3.next();
Assert.assertEquals(r3.getLong(1), 10L);
Assert.assertEquals(r3.getLong(3), 10L);
Assert.assertEquals(r3.getLong(4), 10L);
try (ResultSet r3 =
statement.executeQuery("select * from table1 where device='d0' and s1 = 10")) {
Assert.assertTrue(r3.next());
Assert.assertEquals(r3.getLong(1), 10L);
Assert.assertEquals(r3.getLong(3), 10L);
Assert.assertEquals(r3.getLong(4), 10L);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class JdbcMessages {

// IoTDBDriver
public static final String REGISTER_DRIVER_ERROR =
"Error occurs when registering TsFile driver";
"Error occurs when registering IoTDB driver";
public static final String METHOD_NOT_SUPPORTED = "Method not supported";

// StringUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class JdbcMessages {

// IoTDBDriver
public static final String REGISTER_DRIVER_ERROR =
"注册 TsFile 驱动时发生错误";
"注册 IoTDB 驱动时发生错误";
public static final String METHOD_NOT_SUPPORTED = "不支持此方法";

// StringUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private Config() {
/** If host is provided, without a port. */
static final int IOTDB_DEFAULT_PORT = 6667;

/** TsFile's default series name. */
/** Default series name. */
static final String DEFAULT_SERIES_NAME = "default";

static final String AUTH_USER = "user";
Expand All @@ -51,6 +51,9 @@ private Config() {
static final int RETRY_NUM = 3;
static final long RETRY_INTERVAL_MS = 1000;

static final int DRIVER_MAJOR_VERSION = 4;
static final int DRIVER_MINOR_VERSION = 3;

public static final int DEFAULT_FETCH_SIZE = 5000;
static final int DEFAULT_CONNECTION_TIMEOUT_MS = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,17 +539,20 @@ public boolean allTablesAreSelectable() throws SQLException {

@Override
public String getURL() throws SQLException {
checkConnectionOpen();
// TODO: Return the URL for this DBMS or null if it cannot be generated
return this.connection.getUrl();
}

@Override
public String getUserName() throws SQLException {
checkConnectionOpen();
return connection.getUserName();
}

@Override
public boolean isReadOnly() throws SQLException {
checkConnectionOpen();
try {
return client.getProperties().isReadOnly;
} catch (TException e) {
Expand Down Expand Up @@ -585,6 +588,7 @@ public String getDatabaseProductName() throws SQLException {

@Override
public String getDatabaseProductVersion() throws SQLException {
checkConnectionOpen();
String serverVersion = "";
String sql = "SHOW VERSION";
try (Statement stmt = this.connection.createStatement();
Expand All @@ -606,12 +610,12 @@ public String getDriverName() throws SQLException {

@Override
public int getDriverMajorVersion() {
return 4;
return Config.DRIVER_MAJOR_VERSION;
}

@Override
public int getDriverMinorVersion() {
return 3;
return Config.DRIVER_MINOR_VERSION;
}

@Override
Expand Down Expand Up @@ -681,6 +685,7 @@ public String getStringFunctions() throws SQLException {

@Override
public String getSystemFunctions() throws SQLException {
checkConnectionOpen();
String result = "";
Statement statement = null;
ResultSet resultSet = null;
Expand Down Expand Up @@ -1037,6 +1042,7 @@ public int getMaxColumnsInTable() throws SQLException {

@Override
public int getMaxConnections() throws SQLException {
checkConnectionOpen();
int maxcount = 0;
try {
maxcount = client.getProperties().getMaxConcurrentClientNum();
Expand Down Expand Up @@ -1083,6 +1089,7 @@ public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {

@Override
public int getMaxStatementLength() throws SQLException {
checkConnectionOpen();
try {
return client.getProperties().getThriftMaxFrameSize();
} catch (TException e) {
Expand Down Expand Up @@ -2284,6 +2291,7 @@ public ResultSet getUDTs(

@Override
public Connection getConnection() throws SQLException {
checkConnectionOpen();
return connection;
}

Expand Down Expand Up @@ -2462,6 +2470,7 @@ public int getResultSetHoldability() throws SQLException {

@Override
public int getDatabaseMajorVersion() throws SQLException {
checkConnectionOpen();
int majorVersion = 0;
try {
String version = client.getProperties().getVersion();
Expand All @@ -2477,6 +2486,7 @@ public int getDatabaseMajorVersion() throws SQLException {

@Override
public int getDatabaseMinorVersion() throws SQLException {
checkConnectionOpen();
int minorVersion = 0;
try {
String version = client.getProperties().getVersion();
Expand Down Expand Up @@ -2858,11 +2868,20 @@ public boolean generatedKeyAlwaysReturned() throws SQLException {

@Override
public <T> T unwrap(Class<T> arg0) throws SQLException {
throw new SQLException(METHOD_NOT_SUPPORTED_STRING);
checkConnectionOpen();
return JdbcWrapperUtils.unwrap(this, arg0);
}

@Override
public boolean isWrapperFor(Class<?> arg0) throws SQLException {
throw new SQLException(METHOD_NOT_SUPPORTED_STRING);
checkConnectionOpen();
return JdbcWrapperUtils.isWrapperFor(this, arg0);
}

protected final void checkConnectionOpen() throws SQLException {
if (connection == null || connection.isClosed()) {
throw new SQLException(
String.format(JdbcMessages.CANNOT_AFTER_CONNECTION_CLOSED, "get metadata"));
}
}
}
Loading
Loading