Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -34,6 +34,7 @@
public class TableModelJDBCExample {

private static final Logger LOGGER = LoggerFactory.getLogger(TableModelJDBCExample.class);
private static final String SHOW_TABLES = "SHOW TABLES";

public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
Expand All @@ -57,7 +58,7 @@ public static void main(String[] args) throws ClassNotFoundException, SQLExcepti
"create table table2(region_id STRING TAG, plant_id STRING TAG, color STRING ATTRIBUTE, temperature FLOAT FIELD, speed DOUBLE FIELD) with (TTL=6600000)");

// show tables from current database
try (ResultSet resultSet = statement.executeQuery("SHOW TABLES")) {
try (ResultSet resultSet = statement.executeQuery(SHOW_TABLES)) {
ResultSetMetaData metaData = resultSet.getMetaData();
System.out.println(metaData.getColumnCount());
while (resultSet.next()) {
Expand Down Expand Up @@ -85,7 +86,7 @@ public static void main(String[] args) throws ClassNotFoundException, SQLExcepti
"jdbc:iotdb://127.0.0.1:6667/test1?sql_dialect=table", "root", "root");
Statement statement = connection.createStatement()) {
// show tables from current database test1
try (ResultSet resultSet = statement.executeQuery("SHOW TABLES")) {
try (ResultSet resultSet = statement.executeQuery(SHOW_TABLES)) {
ResultSetMetaData metaData = resultSet.getMetaData();
System.out.println(metaData.getColumnCount());
while (resultSet.next()) {
Expand All @@ -96,7 +97,7 @@ public static void main(String[] args) throws ClassNotFoundException, SQLExcepti
// change database to test2
statement.execute("use test2");

try (ResultSet resultSet = statement.executeQuery("SHOW TABLES")) {
try (ResultSet resultSet = statement.executeQuery(SHOW_TABLES)) {
ResultSetMetaData metaData = resultSet.getMetaData();
System.out.println(metaData.getColumnCount());
while (resultSet.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public class TableModelSessionExample {

private static final String LOCAL_URL = "127.0.0.1:6667";
private static final String SHOW_TABLES = "SHOW TABLES";

public static void main(String[] args) {

Expand All @@ -63,7 +64,7 @@ public static void main(String[] args) {
"create table table2(region_id STRING TAG, plant_id STRING TAG, color STRING ATTRIBUTE, temperature FLOAT FIELD, speed DOUBLE FIELD) with (TTL=6600000)");

// show tables from current database
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW TABLES")) {
try (SessionDataSet dataSet = session.executeQueryStatement(SHOW_TABLES)) {
System.out.println(dataSet.getColumnNames());
while (dataSet.hasNext()) {
System.out.println(dataSet.next());
Expand Down Expand Up @@ -140,7 +141,7 @@ public static void main(String[] args) {
.build()) {

// show tables from current database
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW TABLES")) {
try (SessionDataSet dataSet = session.executeQueryStatement(SHOW_TABLES)) {
printDataSet(dataSet);
}

Expand All @@ -149,7 +150,7 @@ public static void main(String[] args) {

// show tables by specifying another database
// using SHOW tables FROM
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW TABLES")) {
try (SessionDataSet dataSet = session.executeQueryStatement(SHOW_TABLES)) {
printDataSet(dataSet);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
public class TableModelSessionPoolExample {

private static final String LOCAL_URL = "127.0.0.1:6667";
private static final String SHOW_TABLES = "SHOW TABLES";

public static void main(String[] args) {

Expand Down Expand Up @@ -78,7 +79,7 @@ public static void main(String[] args) {
+ "speed DOUBLE FIELD) with (TTL=6600000)");

// show tables from current database
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW TABLES")) {
try (SessionDataSet dataSet = session.executeQueryStatement(SHOW_TABLES)) {
printDataSet(dataSet);
}

Expand Down Expand Up @@ -157,7 +158,7 @@ public static void main(String[] args) {
try (ITableSession session = tableSessionPool.getSession()) {

// show tables from current database
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW TABLES")) {
try (SessionDataSet dataSet = session.executeQueryStatement(SHOW_TABLES)) {
printDataSet(dataSet);
}

Expand All @@ -166,7 +167,7 @@ public static void main(String[] args) {

// show tables by specifying another database
// using SHOW tables FROM
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW TABLES")) {
try (SessionDataSet dataSet = session.executeQueryStatement(SHOW_TABLES)) {
printDataSet(dataSet);
}

Expand All @@ -179,7 +180,7 @@ public static void main(String[] args) {
try (ITableSession session = tableSessionPool.getSession()) {

// show tables from default database test1
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW TABLES")) {
try (SessionDataSet dataSet = session.executeQueryStatement(SHOW_TABLES)) {
printDataSet(dataSet);
}

Expand Down