diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableLoader.java
deleted file mode 100644
index 5b44762487e3f..0000000000000
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableLoader.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2016-2018 shardingsphere.io.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package io.shardingsphere.core.metadata.table.executor;
-
-import lombok.RequiredArgsConstructor;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * Table loader.
- *
- * @author zhangliang
- */
-@RequiredArgsConstructor
-public final class TableLoader {
-
- private final TableMetaDataExecutorAdapter executorAdapter;
-
- /**
- * Get all table names.
- *
- * @param dataSourceName data source name
- * @return table names
- * @throws SQLException SQL exception
- */
- public Collection getAllTableNames(final String dataSourceName) throws SQLException {
- Collection result = new LinkedList<>();
- try (Connection connection = executorAdapter.getConnection(dataSourceName);
- ResultSet resultSet = connection.getMetaData().getTables(null, null, null, null)) {
- while (resultSet.next()) {
- result.add(resultSet.getString("TABLE_NAME"));
- }
- }
- return result;
- }
-}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataInitializer.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataInitializer.java
index d1b4958627551..e1abde8dbd0c0 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataInitializer.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataInitializer.java
@@ -24,8 +24,12 @@
import io.shardingsphere.core.rule.ShardingRule;
import io.shardingsphere.core.rule.TableRule;
+import java.sql.Connection;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.Map;
/**
@@ -35,12 +39,12 @@
*/
public final class TableMetaDataInitializer {
- private final TableLoader tableLoader;
+ private final TableMetaDataExecutorAdapter executorAdapter;
private final TableMetaDataLoader tableMetaDataLoader;
public TableMetaDataInitializer(final ListeningExecutorService executorService, final TableMetaDataExecutorAdapter executorAdapter) {
- tableLoader = new TableLoader(executorAdapter);
+ this.executorAdapter = executorAdapter;
tableMetaDataLoader = new TableMetaDataLoader(executorService, executorAdapter);
}
@@ -72,10 +76,21 @@ private Map loadDefaultTables(final ShardingRule sharding
Map result = new HashMap<>(shardingRule.getTableRules().size(), 1);
Optional actualDefaultDataSourceName = shardingRule.findActualDefaultDataSourceName();
if (actualDefaultDataSourceName.isPresent()) {
- for (String each : tableLoader.getAllTableNames(actualDefaultDataSourceName.get())) {
+ for (String each : getAllTableNames(actualDefaultDataSourceName.get())) {
result.put(each, tableMetaDataLoader.loadTableMetaData(each, shardingRule));
}
}
return result;
}
+
+ private Collection getAllTableNames(final String dataSourceName) throws SQLException {
+ Collection result = new LinkedList<>();
+ try (Connection connection = executorAdapter.getConnection(dataSourceName);
+ ResultSet resultSet = connection.getMetaData().getTables(null, null, null, null)) {
+ while (resultSet.next()) {
+ result.add(resultSet.getString("TABLE_NAME"));
+ }
+ }
+ return result;
+ }
}