diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/StorageResourceCreator.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/StorageResourceCreator.java index 7880cb328c6eb..8f1bf5c93a071 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/StorageResourceCreator.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/StorageResourceCreator.java @@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.database.core.connector.url.JdbcUrl; import org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser; import org.apache.shardingsphere.infra.database.core.connector.url.UnrecognizedDatabaseURLException; -import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeFactory; import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry; import org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator; @@ -54,10 +53,8 @@ public static StorageResource createStorageResource(final Map standardProps = entry.getValue().getConnectionPropertySynonyms().getStandardProperties(); String url = standardProps.get("url").toString(); - String username = standardProps.get("username").toString(); - DatabaseType databaseType = DatabaseTypeFactory.get(url); - boolean isInstanceConnectionAvailable = new DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().isInstanceConnectionAvailable(); - StorageNode storageNode = new StorageNode(getStorageNodeName(storageUnitName, url, username, isInstanceConnectionAvailable)); + boolean isInstanceConnectionAvailable = new DatabaseTypeRegistry(DatabaseTypeFactory.get(url)).getDialectDatabaseMetaData().isInstanceConnectionAvailable(); + StorageNode storageNode = new StorageNode(getStorageNodeName(storageUnitName, url, standardProps.get("username").toString(), isInstanceConnectionAvailable)); if (!storageNodes.containsKey(storageNode)) { storageNodes.put(storageNode, DataSourcePoolCreator.create(storageUnitName, entry.getValue(), true, storageNodes.values())); } @@ -99,10 +96,8 @@ public static StorageResource createStorageResourceWithoutDataSource(final Map standardProps = entry.getValue().getConnectionPropertySynonyms().getStandardProperties(); String url = standardProps.get("url").toString(); - String username = standardProps.get("username").toString(); - DatabaseType databaseType = DatabaseTypeFactory.get(url); - boolean isInstanceConnectionAvailable = new DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().isInstanceConnectionAvailable(); - StorageNode storageNode = new StorageNode(getStorageNodeName(entry.getKey(), url, username, isInstanceConnectionAvailable)); + boolean isInstanceConnectionAvailable = new DatabaseTypeRegistry(DatabaseTypeFactory.get(url)).getDialectDatabaseMetaData().isInstanceConnectionAvailable(); + StorageNode storageNode = new StorageNode(getStorageNodeName(storageUnitName, url, standardProps.get("username").toString(), isInstanceConnectionAvailable)); if (!storageNodes.containsKey(storageNode)) { storageNodes.put(storageNode, null); newPropsMap.put(storageNode.getName(), entry.getValue());