Skip to content

Commit

Permalink
fix jdbc zone
Browse files Browse the repository at this point in the history
  • Loading branch information
Cpaulyz committed May 21, 2024
1 parent 228bba7 commit fd89986
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.ZoneId;
import java.util.BitSet;
import java.util.Calendar;
import java.util.List;
Expand Down Expand Up @@ -78,7 +79,8 @@ public AbstractIoTDBJDBCResultSet(
long sessionId,
long timeout,
List<String> sgColumns,
BitSet aliasColumnMap)
BitSet aliasColumnMap,
ZoneId zoneId)
throws SQLException {
this.ioTDBRpcDataSet =
new IoTDBJDBCDataSet(
Expand All @@ -95,7 +97,8 @@ public AbstractIoTDBJDBCResultSet(
statement.getFetchSize(),
timeout,
sgColumns,
aliasColumnMap);
aliasColumnMap,
zoneId);
this.statement = statement;
this.columnTypeList = columnTypeList;
this.aliasColumnMap = aliasColumnMap;
Expand All @@ -113,7 +116,8 @@ protected AbstractIoTDBJDBCResultSet(
long queryId,
long sessionId,
long timeout,
boolean isRpcFetchResult)
boolean isRpcFetchResult,
ZoneId zoneId)
throws SQLException {
this.ioTDBRpcDataSet =
new IoTDBJDBCDataSet(
Expand All @@ -128,7 +132,8 @@ protected AbstractIoTDBJDBCResultSet(
sessionId,
null,
statement.getFetchSize(),
timeout);
timeout,
zoneId);
this.statement = statement;
this.columnTypeList = columnTypeList;
this.isRpcFetchResult = isRpcFetchResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public DatabaseMetaData getMetaData() throws SQLException {
if (isClosed) {
throw new SQLException("Cannot create statement because connection is closed");
}
return new IoTDBDatabaseMetadata(this, getClient(), sessionId);
return new IoTDBDatabaseMetadata(this, getClient(), sessionId, zoneId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -69,6 +70,7 @@ public class IoTDBDatabaseMetadata implements DatabaseMetaData {
? IoTDBDatabaseMetadata.class.getPackage().getImplementationVersion()
: "UNKNOWN";
private long sessionId;
private ZoneId zoneId;
private static String sqlKeywordsThatArentSQL92;
private static TsBlockSerde serde = new TsBlockSerde();

Expand Down Expand Up @@ -145,10 +147,11 @@ public class IoTDBDatabaseMetadata implements DatabaseMetaData {
private static final String CONVERT_ERROR_MSG = "convert tsBlock error: {}";

IoTDBDatabaseMetadata(
IoTDBConnection connection, IClientRPCService.Iface client, long sessionId) {
IoTDBConnection connection, IClientRPCService.Iface client, long sessionId, ZoneId zoneId) {
this.connection = connection;
this.client = client;
this.sessionId = sessionId;
this.zoneId = zoneId;
}

static {
Expand Down Expand Up @@ -675,7 +678,8 @@ public ResultSet getAttributes(String arg0, String arg1, String arg2, String arg
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -720,7 +724,8 @@ public ResultSet getBestRowIdentifier(
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -784,7 +789,8 @@ public ResultSet getCatalogs() throws SQLException {
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

public static ByteBuffer convertTsBlock(
Expand Down Expand Up @@ -890,7 +896,8 @@ public ResultSet getClientInfoProperties() throws SQLException {
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@SuppressWarnings({
Expand Down Expand Up @@ -1012,7 +1019,8 @@ public ResultSet getColumnPrivileges(
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1067,7 +1075,8 @@ public ResultSet getCrossReference(
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1181,7 +1190,8 @@ public ResultSet getExportedKeys(String catalog, String schema, final String tab
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1290,7 +1300,8 @@ public ResultSet getFunctionColumns(
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@SuppressWarnings(
Expand Down Expand Up @@ -1368,7 +1379,8 @@ public ResultSet getFunctions(String catalog, String schemaPattern, String funct
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1421,7 +1433,8 @@ public ResultSet getImportedKeys(String arg0, String arg1, String arg2) throws S
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1470,7 +1483,8 @@ public ResultSet getIndexInfo(String arg0, String arg1, String arg2, boolean arg
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1689,7 +1703,8 @@ public ResultSet getPrimaryKeys(String catalog, String schema, String table) thr
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1745,7 +1760,8 @@ public ResultSet getProcedureColumns(String arg0, String arg1, String arg2, Stri
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1790,7 +1806,8 @@ public ResultSet getProcedures(String arg0, String arg1, String arg2) throws SQL
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1860,7 +1877,8 @@ public ResultSet getPseudoColumns(
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1945,7 +1963,8 @@ public ResultSet getSchemas() throws SQLException {
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -1999,7 +2018,8 @@ public ResultSet getSuperTables(String catalog, String schemaPattern, String tab
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -2040,7 +2060,8 @@ public ResultSet getSuperTypes(String catalog, String schemaPattern, String type
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -2176,7 +2197,8 @@ public ResultSet getTablePrivileges(String catalog, String schemaPattern, String
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -2216,7 +2238,8 @@ public ResultSet getTableTypes() throws SQLException {
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@SuppressWarnings({
Expand Down Expand Up @@ -2417,7 +2440,8 @@ public ResultSet getColumns(
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

private void close(ResultSet rs, Statement stmt) {
Expand Down Expand Up @@ -2616,7 +2640,8 @@ public ResultSet getTables(
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -2818,7 +2843,8 @@ public ResultSet getTypeInfo() throws SQLException {
Collections.singletonList(tsBlock),
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -2861,7 +2887,8 @@ public ResultSet getUDTs(
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down Expand Up @@ -2915,7 +2942,8 @@ public ResultSet getVersionColumns(String catalog, String schema, String table)
null,
null,
(long) 60 * 1000,
false);
false,
zoneId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public class IoTDBJDBCResultSet implements ResultSet {
private String operationType = "";
private List<String> columns = null;
private List<String> sgColumns = null;
private ZoneId zoneId = ZoneId.systemDefault();
private String timeFormat = RpcUtils.DEFAULT_TIME_FORMAT;

@SuppressWarnings("squid:S107") // ignore Methods should not have too many parameters
Expand All @@ -91,7 +90,8 @@ public IoTDBJDBCResultSet(
List<String> columns,
List<String> sgColumns,
BitSet aliasColumnMap,
boolean moreData)
boolean moreData,
ZoneId zoneId)
throws SQLException {
this.ioTDBRpcDataSet =
new IoTDBRpcDataSet(
Expand Down Expand Up @@ -137,7 +137,8 @@ public IoTDBJDBCResultSet(
List<ByteBuffer> dataSet,
TSTracingInfo tracingInfo,
long timeout,
boolean moreData)
boolean moreData,
ZoneId zoneId)
throws SQLException {
this.ioTDBRpcDataSet =
new IoTDBRpcDataSet(
Expand Down Expand Up @@ -1275,8 +1276,4 @@ public List<String> getColumns() {
public List<String> getSgColumns() {
return sgColumns;
}

public void setZoneId(ZoneId zoneId) {
this.zoneId = zoneId;
}
}
Loading

0 comments on commit fd89986

Please sign in to comment.