You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/04/23 04:32:37 UTC
[shardingsphere] branch master updated: Modify checkout and spotless rules (#17018)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 3901a212be4 Modify checkout and spotless rules (#17018)
3901a212be4 is described below
commit 3901a212be4009b45919eb66ca1ca8826d6103ca
Author: 龙台 Long Tai <77...@users.noreply.github.com>
AuthorDate: Sat Apr 23 12:32:29 2022 +0800
Modify checkout and spotless rules (#17018)
* Code formatting
* Modify checkstyle and eclipse formatter rules
* Modify plug-in execution order
---
pom.xml | 46 +++++-----
.../agent/core/config/yaml/engine/YamlEngine.java | 5 +-
.../agent/plugin/tracing/AgentRunner.java | 6 +-
.../packet/handshake/MySQLRandomGenerator.java | 6 +-
.../bind/OpenGaussComBatchBindPacketTest.java | 22 ++---
.../extended/bind/PostgreSQLComBindPacketTest.java | 8 +-
...YamlDatabaseDiscoveryRuleConfigurationTest.java | 5 +-
.../mysql/AbstractDatabaseDiscoveryType.java | 5 +-
.../MasterSlaveDatabaseDiscoveryType.java | 10 +-
.../mysql/type/mgr/MGRDatabaseDiscoveryType.java | 10 +-
.../opengauss/OpenGaussDatabaseDiscoveryType.java | 14 +--
...amlReadwriteSplittingRuleConfigurationTest.java | 5 +-
...urationsForYamlShadowRuleConfigurationTest.java | 5 +-
...ationsForYamlShardingRuleConfigurationTest.java | 5 +-
.../loader/dialect/MySQLSchemaMetaDataLoader.java | 15 +--
.../dialect/OpenGaussSchemaMetaDataLoader.java | 10 +-
.../dialect/PostgreSQLSchemaMetaDataLoader.java | 5 +-
.../dialect/SQLServerSchemaMetaDataLoader.java | 10 +-
.../infra/yaml/engine/YamlEngine.java | 5 +-
.../infra/yaml/engine/YamlEngineTest.java | 10 +-
.../datetime/database/DatabaseDatetimeService.java | 5 +-
.../impl/AggregationProjectionConverter.java | 2 +-
.../impl/ExpressionProjectionConverter.java | 2 +-
.../jdbc/core/resultset/EncryptResultSetTest.java | 35 ++++---
.../statement/EncryptPreparedStatementTest.java | 5 +-
.../jdbc/core/statement/EncryptStatementTest.java | 5 +-
.../ReadwriteSplittingPreparedStatementTest.java | 5 +-
.../ShardingSpherePreparedStatementTest.java | 72 +++++++++------
.../statement/ShardingSphereStatementTest.java | 5 +-
.../builder/dialect/MySQLPrivilegeHandler.java | 28 +++---
.../builder/dialect/OraclePrivilegeHandler.java | 21 +++--
.../dialect/PostgreSQLPrivilegeHandler.java | 21 +++--
.../builder/dialect/SQLServerPrivilegeHandler.java | 28 +++---
.../check/consistency/DataConsistencyChecker.java | 17 ++--
...RC32MatchDataConsistencyCalculateAlgorithm.java | 7 +-
...DataMatchDataConsistencyCalculateAlgorithm.java | 5 +-
.../datasource/AbstractDataSourceChecker.java | 7 +-
.../rulealtered/prepare/InventoryTaskSplitter.java | 5 +-
.../job/environment/ScalingEnvironmentManager.java | 5 +-
.../check/datasource/MySQLDataSourceChecker.java | 7 +-
.../mysql/ingest/MySQLPositionInitializer.java | 10 +-
.../datasource/MySQLDataSourcePreparer.java | 5 +-
.../mysql/ingest/MySQLIncrementalDumperTest.java | 5 +-
.../pipeline/mysql/ingest/MySQLJdbcDumperTest.java | 5 +-
.../ingest/OpenGaussPositionInitializer.java | 5 +-
.../ingest/wal/decode/MppdbDecodingPluginTest.java | 4 +-
.../ingest/PostgreSQLPositionInitializer.java | 5 +-
.../postgresql/ingest/PostgreSQLWalDumper.java | 5 +-
.../datasource/PostgreSQLDataSourcePreparer.java | 25 +++--
.../ingest/PostgreSQLJdbcDumperTest.java | 10 +-
.../ingest/wal/WalEventConverterTest.java | 5 +-
.../repository/standalone/h2/H2Repository.java | 10 +-
.../executor/AbstractDatabaseMetadataExecutor.java | 7 +-
.../sql/parser/mysql/MySQLFormatTest.java | 52 +++++------
.../sql/parser/mysql/MySQLParameterizedTest.java | 16 ++--
.../sql/parser/mysql/MySQLTableVistorTest.java | 2 +-
.../common/env/IntegrationTestEnvironment.java | 5 +-
...hardingWithReadwriteSplittingIntegrateTest.java | 13 +--
.../YamlReadwriteSplittingIntegrateTest.java | 18 ++--
.../driver/sharding/YamlShardingIntegrateTest.java | 13 +--
.../data/pipline/fixture/DataImporter.java | 5 +-
.../test/integration/engine/BatchITCase.java | 5 +-
.../test/integration/engine/dal/GeneralDALIT.java | 5 +-
.../test/integration/engine/dml/BaseDMLIT.java | 5 +-
.../test/integration/engine/dml/BatchDMLIT.java | 5 +-
.../integration/engine/dql/AdditionalDQLIT.java | 102 ++++++++++++---------
.../test/integration/engine/dql/GeneralDQLIT.java | 49 ++++++----
.../test/integration/engine/ral/GeneralRALIT.java | 5 +-
.../test/integration/engine/rdl/GeneralRDLIT.java | 5 +-
.../test/integration/engine/rql/GeneralRQLIT.java | 5 +-
.../dataset/DataSetEnvironmentManager.java | 5 +-
.../container/atomic/storage/impl/H2Container.java | 5 +-
.../impl/PostgreSQLDatabaseAssertionMetaData.java | 7 +-
.../integration/framework/watcher/ITWatcher.java | 5 +-
.../core/api/impl/RuleAlteredJobAPIImplTest.java | 5 +-
.../consistency/DataConsistencyCheckerTest.java | 5 +-
.../data/pipeline/core/task/InventoryTaskTest.java | 23 +++--
.../scenario/rulealtered/RuleAlteredJobTest.java | 7 +-
.../prepare/InventoryTaskSplitterTest.java | 25 +++--
src/resources/checkstyle_ci.xml | 5 +-
src/resources/shardingsphere_eclipse_formatter.xml | 4 +-
81 files changed, 574 insertions(+), 427 deletions(-)
diff --git a/pom.xml b/pom.xml
index 04db83595b6..2217809a2f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1048,6 +1048,29 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <eclipse>
+ <file>src/resources/shardingsphere_eclipse_formatter.xml</file>
+ </eclipse>
+ <licenseHeader>
+ <file>src/resources/license-header</file>
+ </licenseHeader>
+ </java>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>apply</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
@@ -1184,29 +1207,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>com.diffplug.spotless</groupId>
- <artifactId>spotless-maven-plugin</artifactId>
- <version>${spotless-maven-plugin.version}</version>
- <configuration>
- <java>
- <eclipse>
- <file>src/resources/shardingsphere_eclipse_formatter.xml</file>
- </eclipse>
- <licenseHeader>
- <file>src/resources/license-header</file>
- </licenseHeader>
- </java>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>apply</goal>
- </goals>
- <phase>compile</phase>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/yaml/engine/YamlEngine.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/yaml/engine/YamlEngine.java
index c80dfc09456..20f6e563972 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/yaml/engine/YamlEngine.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/yaml/engine/YamlEngine.java
@@ -41,8 +41,9 @@ public final class YamlEngine {
* @throws IOException IO Exception
*/
public static <T> T unmarshal(final File yamlFile, final Class<T> classType) throws IOException {
- try (FileInputStream fileInputStream = new FileInputStream(yamlFile);
- InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)) {
+ try (
+ FileInputStream fileInputStream = new FileInputStream(yamlFile);
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)) {
return new Yaml().loadAs(inputStreamReader, classType);
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/AgentRunner.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/AgentRunner.java
index 37251071c06..a07e586984a 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/AgentRunner.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/AgentRunner.java
@@ -47,9 +47,9 @@ public final class AgentRunner extends BlockJUnit4ClassRunner {
private static ResettableClassFileTransformer byteBuddyAgent;
private static final String[] ENHANCEMENT_CLASSES = {
- "org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask",
- "org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback",
- "org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine",
+ "org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask",
+ "org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback",
+ "org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine",
};
private CollectorRule collectorRule;
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLRandomGenerator.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLRandomGenerator.java
index e1cfaee1ed6..929a87a1874 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLRandomGenerator.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLRandomGenerator.java
@@ -34,9 +34,9 @@ public final class MySQLRandomGenerator {
private static final MySQLRandomGenerator INSTANCE = new MySQLRandomGenerator();
private static final byte[] SEED = {
- 'a', 'b', 'e', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
+ 'a', 'b', 'e', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
private final Random random = ThreadLocalRandom.current();
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/test/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/query/extended/bind/OpenGaussComBatchBindPacketTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/test/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/query/extended/bind/OpenGaussComBatchBindPacketTest.java
index 7e62a313844..0bd92ee9ab8 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/test/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/query/extended/bind/OpenGaussComBatchBindPacketTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/test/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/query/extended/bind/OpenGaussComBatchBindPacketTest.java
@@ -36,17 +36,17 @@ import static org.junit.Assert.assertTrue;
public final class OpenGaussComBatchBindPacketTest {
private static final byte[] BATCH_BIND_MESSAGE_BYTES = {
- 'U', 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00,
- 0x03, 0x00, 'S', '_', '1', 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x31, 0x00,
- 0x00, 0x00, 0x03, 0x46, 0x6f, 0x6f, 0x00, 0x00,
- 0x00, 0x02, 0x31, 0x38, 0x00, 0x00, 0x00, 0x01,
- 0x32, 0x00, 0x00, 0x00, 0x03, 0x42, 0x61, 0x72,
- 0x00, 0x00, 0x00, 0x02, 0x33, 0x36, 0x00, 0x00,
- 0x00, 0x01, 0x33, 0x00, 0x00, 0x00, 0x03, 0x54,
- 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x02, 0x35, 0x34,
- 0x45, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 'U', 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 'S', '_', '1', 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x31, 0x00,
+ 0x00, 0x00, 0x03, 0x46, 0x6f, 0x6f, 0x00, 0x00,
+ 0x00, 0x02, 0x31, 0x38, 0x00, 0x00, 0x00, 0x01,
+ 0x32, 0x00, 0x00, 0x00, 0x03, 0x42, 0x61, 0x72,
+ 0x00, 0x00, 0x00, 0x02, 0x33, 0x36, 0x00, 0x00,
+ 0x00, 0x01, 0x33, 0x00, 0x00, 0x00, 0x03, 0x54,
+ 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x02, 0x35, 0x34,
+ 0x45, 0x00, 0x00, 0x00, 0x00, 0x00,
};
private static final int CONNECTION_ID = 1;
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacketTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacketTest.java
index 1525628a06b..f87a2bad84d 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacketTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacketTest.java
@@ -36,10 +36,10 @@ import static org.mockito.Mockito.mock;
public final class PostgreSQLComBindPacketTest {
private static final byte[] BIND_MESSAGE_BYTES = {
- 0x00, 0x00, 0x00, 0x19, 0x00, 0x53, 0x5f,
- 0x31, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a,
- 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x19, 0x00, 0x53, 0x5f,
+ 0x31, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a,
+ 0x00, 0x00,
};
@Test
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/YamlRootRuleConfigurationsForYamlDatabaseDiscoveryRuleConfigurationTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/YamlRootRuleConfigurationsForYamlDatabaseDiscoveryRuleConfigurationTest.java
index 482c5a0a3d3..74bece9e61c 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/YamlRootRuleConfigurationsForYamlDatabaseDiscoveryRuleConfigurationTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/YamlRootRuleConfigurationsForYamlDatabaseDiscoveryRuleConfigurationTest.java
@@ -49,8 +49,9 @@ public final class YamlRootRuleConfigurationsForYamlDatabaseDiscoveryRuleConfigu
URL url = getClass().getClassLoader().getResource("yaml/db-discovery-rule.yaml");
assertNotNull(url);
StringBuilder yamlContent = new StringBuilder();
- try (FileReader fileReader = new FileReader(url.getFile());
- BufferedReader reader = new BufferedReader(fileReader)) {
+ try (
+ FileReader fileReader = new FileReader(url.getFile());
+ BufferedReader reader = new BufferedReader(fileReader)) {
String line;
while (null != (line = reader.readLine())) {
yamlContent.append(line).append(System.lineSeparator());
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/AbstractDatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/AbstractDatabaseDiscoveryType.java
index 6a546b3f697..f90b4e9899a 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/AbstractDatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/AbstractDatabaseDiscoveryType.java
@@ -47,8 +47,9 @@ public abstract class AbstractDatabaseDiscoveryType implements DatabaseDiscovery
private String loadPrimaryDataSourceURL(final Map<String, DataSource> dataSourceMap) {
for (DataSource each : dataSourceMap.values()) {
- try (Connection connection = each.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = each.getConnection();
+ Statement statement = connection.createStatement()) {
Optional<String> primaryDataSourceURL = loadPrimaryDataSourceURL(statement);
if (primaryDataSourceURL.isPresent()) {
return primaryDataSourceURL.get();
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/masterslave/MasterSlaveDatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/masterslave/MasterSlaveDatabaseDiscoveryType.java
index 0fb30ad2907..562445caf0c 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/masterslave/MasterSlaveDatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/masterslave/MasterSlaveDatabaseDiscoveryType.java
@@ -51,8 +51,9 @@ public final class MasterSlaveDatabaseDiscoveryType extends AbstractDatabaseDisc
@Override
public MasterSlaveHighlyAvailableStatus loadHighlyAvailableStatus(final DataSource dataSource) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
return new MasterSlaveHighlyAvailableStatus(loadPrimaryDataSourceURL(statement).orElse(null));
}
}
@@ -82,8 +83,9 @@ public final class MasterSlaveDatabaseDiscoveryType extends AbstractDatabaseDisc
}
private void determineDatasourceState(final String databaseName, final String datasourceName, final DataSource dataSource, final String groupName) {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
long replicationDelayMilliseconds = getSecondsBehindMaster(statement) * 1000L;
if (replicationDelayMilliseconds < Long.parseLong(props.getProperty("delay-milliseconds-threshold"))) {
ShardingSphereEventBus.getInstance().post(new DataSourceDisabledEvent(databaseName, groupName, datasourceName,
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/mgr/MGRDatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/mgr/MGRDatabaseDiscoveryType.java
index 9ef0269701e..9e721a47ea6 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/mgr/MGRDatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/mgr/MGRDatabaseDiscoveryType.java
@@ -63,8 +63,9 @@ public final class MGRDatabaseDiscoveryType extends AbstractDatabaseDiscoveryTyp
@Override
public MGRHighlyAvailableStatus loadHighlyAvailableStatus(final DataSource dataSource) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
return new MGRHighlyAvailableStatus(queryIsPluginActive(statement), queryIsSinglePrimaryMode(statement), queryGroupName(statement), queryMemberInstanceURLs(statement));
}
}
@@ -118,8 +119,9 @@ public final class MGRDatabaseDiscoveryType extends AbstractDatabaseDiscoveryTyp
private List<String> findMemberDataSourceURLs(final Map<String, DataSource> dataSourceMap) {
List<String> result = new LinkedList<>();
- try (Connection connection = dataSourceMap.get(getPrimaryDataSource()).getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSourceMap.get(getPrimaryDataSource()).getConnection();
+ Statement statement = connection.createStatement()) {
ResultSet resultSet = statement.executeQuery(QUERY_MEMBER_LIST);
while (resultSet.next()) {
if (!"ONLINE".equals(resultSet.getString("MEMBER_STATE"))) {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
index 0982cafa2f9..3aa7fb9374b 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
@@ -63,9 +63,10 @@ public final class OpenGaussDatabaseDiscoveryType implements DatabaseDiscoveryTy
@Override
public Optional<String> determinePrimaryDataSource(final Map<String, DataSource> dataSourceMap) {
for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
- try (Connection connection = entry.getValue().getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(DB_ROLE)) {
+ try (
+ Connection connection = entry.getValue().getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(DB_ROLE)) {
if (resultSet.next()) {
if (resultSet.getString("local_role").equals("Primary") && resultSet.getString("db_state").equals("Normal")) {
return Optional.of(entry.getKey());
@@ -82,9 +83,10 @@ public final class OpenGaussDatabaseDiscoveryType implements DatabaseDiscoveryTy
public void updateMemberState(final String databaseName, final Map<String, DataSource> dataSourceMap, final String groupName) {
for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
boolean disable = true;
- try (Connection connection = entry.getValue().getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(DB_ROLE)) {
+ try (
+ Connection connection = entry.getValue().getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(DB_ROLE)) {
if (resultSet.next()) {
if ((resultSet.getString("local_role").equals("Standby") && resultSet.getString("db_state").equals("Normal"))
|| entry.getKey().equals(oldPrimaryDataSource)) {
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/swapper/YamlRootRuleConfigurationsForYamlReadwriteSplittingRuleConfigurationTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/swapper/YamlRootRuleConfigurationsForYamlReadwriteSplittingRuleConfiguration [...]
index 6974fb10e3d..532f1cae4a9 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/swapper/YamlRootRuleConfigurationsForYamlReadwriteSplittingRuleConfigurationTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/swapper/YamlRootRuleConfigurationsForYamlReadwriteSplittingRuleConfigurationTest.java
@@ -48,8 +48,9 @@ public final class YamlRootRuleConfigurationsForYamlReadwriteSplittingRuleConfig
URL url = getClass().getClassLoader().getResource("yaml/readwrite-splitting-rule.yaml");
assertNotNull(url);
StringBuilder yamlContent = new StringBuilder();
- try (FileReader fileReader = new FileReader(url.getFile());
- BufferedReader reader = new BufferedReader(fileReader)) {
+ try (
+ FileReader fileReader = new FileReader(url.getFile());
+ BufferedReader reader = new BufferedReader(fileReader)) {
String line;
while (null != (line = reader.readLine())) {
yamlContent.append(line).append(System.lineSeparator());
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/YamlRootRuleConfigurationsForYamlShadowRuleConfigurationTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/YamlRootRuleConfigurationsForYamlShadowRuleConfigurationTest.java
index bc969847a8e..d72925877ec 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/YamlRootRuleConfigurationsForYamlShadowRuleConfigurationTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/YamlRootRuleConfigurationsForYamlShadowRuleConfigurationTest.java
@@ -46,8 +46,9 @@ public final class YamlRootRuleConfigurationsForYamlShadowRuleConfigurationTest
URL url = getClass().getClassLoader().getResource("yaml/shadow-rule.yaml");
assertNotNull(url);
StringBuilder yamlContent = new StringBuilder();
- try (FileReader fileReader = new FileReader(url.getFile());
- BufferedReader reader = new BufferedReader(fileReader)) {
+ try (
+ FileReader fileReader = new FileReader(url.getFile());
+ BufferedReader reader = new BufferedReader(fileReader)) {
String line;
while (null != (line = reader.readLine())) {
yamlContent.append(line).append(System.lineSeparator());
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/swapper/YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/swapper/YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTest.java
index a357e3194f4..b2791ede440 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/swapper/YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/swapper/YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTest.java
@@ -49,8 +49,9 @@ public final class YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTes
URL url = getClass().getClassLoader().getResource("yaml/sharding-rule.yaml");
assertNotNull(url);
StringBuilder yamlContent = new StringBuilder();
- try (FileReader fileReader = new FileReader(url.getFile());
- BufferedReader reader = new BufferedReader(fileReader)) {
+ try (
+ FileReader fileReader = new FileReader(url.getFile());
+ BufferedReader reader = new BufferedReader(fileReader)) {
String line;
while (null != (line = reader.readLine())) {
yamlContent.append(line).append(System.lineSeparator());
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/MySQLSchemaMetaDataLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/MySQLSchemaMetaDataLoader.java
index ec3a3491651..65005d1d248 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/MySQLSchemaMetaDataLoader.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/MySQLSchemaMetaDataLoader.java
@@ -76,8 +76,9 @@ public final class MySQLSchemaMetaDataLoader implements DialectSchemaMetaDataLoa
private Map<String, Collection<ConstraintMetaData>> loadConstraintMetaDataMap(final DataSource dataSource, final Collection<String> tables) throws SQLException {
Map<String, Collection<ConstraintMetaData>> result = new LinkedHashMap<>();
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getConstraintMetaDataSQL(tables))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getConstraintMetaDataSQL(tables))) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
String constraintName = resultSet.getString("CONSTRAINT_NAME");
@@ -99,8 +100,9 @@ public final class MySQLSchemaMetaDataLoader implements DialectSchemaMetaDataLoa
private Map<String, Collection<ColumnMetaData>> loadColumnMetaDataMap(final DataSource dataSource, final Collection<String> tables) throws SQLException {
Map<String, Collection<ColumnMetaData>> result = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getTableMetaDataSQL(tables))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getTableMetaDataSQL(tables))) {
Map<String, Integer> dataTypes = DataTypeLoader.load(connection.getMetaData());
appendDataTypes(dataTypes);
String databaseName = "".equals(connection.getCatalog()) ? GlobalDataSourceRegistry.getInstance().getCachedDatabaseTables().get(tables.iterator().next()) : connection.getCatalog();
@@ -141,8 +143,9 @@ public final class MySQLSchemaMetaDataLoader implements DialectSchemaMetaDataLoa
private Map<String, Collection<IndexMetaData>> loadIndexMetaData(final DataSource dataSource, final Collection<String> tableNames) throws SQLException {
Map<String, Collection<IndexMetaData>> result = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getIndexMetaDataSQL(tableNames))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getIndexMetaDataSQL(tableNames))) {
preparedStatement.setString(1, connection.getCatalog());
String databaseName = "".equals(connection.getCatalog()) ? GlobalDataSourceRegistry.getInstance().getCachedDatabaseTables().get(tableNames.iterator().next()) : connection.getCatalog();
preparedStatement.setString(1, databaseName);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/OpenGaussSchemaMetaDataLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/OpenGaussSchemaMetaDataLoader.java
index fb580893d34..e5f6e65d616 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/OpenGaussSchemaMetaDataLoader.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/OpenGaussSchemaMetaDataLoader.java
@@ -77,8 +77,9 @@ public final class OpenGaussSchemaMetaDataLoader implements DialectSchemaMetaDat
private Map<String, Collection<ColumnMetaData>> loadColumnMetaDataMap(final DataSource dataSource, final Collection<String> existedTables) throws SQLException {
Map<String, Collection<ColumnMetaData>> result = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getTableMetaDataSQL(existedTables))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getTableMetaDataSQL(existedTables))) {
Map<String, Integer> dataTypes = DataTypeLoader.load(connection.getMetaData());
Set<String> primaryKeys = loadPrimaryKeys(connection);
preparedStatement.setString(1, connection.getSchema());
@@ -128,8 +129,9 @@ public final class OpenGaussSchemaMetaDataLoader implements DialectSchemaMetaDat
private Map<String, Collection<IndexMetaData>> loadIndexMetaDataMap(final DataSource dataSource) throws SQLException {
Map<String, Collection<IndexMetaData>> result = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(BASIC_INDEX_META_DATA_SQL)) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(BASIC_INDEX_META_DATA_SQL)) {
preparedStatement.setString(1, connection.getSchema());
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/PostgreSQLSchemaMetaDataLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/PostgreSQLSchemaMetaDataLoader.java
index 4240b8dab35..1401a14e331 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/PostgreSQLSchemaMetaDataLoader.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/PostgreSQLSchemaMetaDataLoader.java
@@ -165,8 +165,9 @@ public final class PostgreSQLSchemaMetaDataLoader implements DialectSchemaMetaDa
private Collection<String> loadRoleTableGrants(final DataSource dataSource, final Collection<String> tables) throws SQLException {
Collection<String> result = new HashSet<>(tables.size(), 1);
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getLoadRoleTableGrantsSQL(tables))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getLoadRoleTableGrantsSQL(tables))) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
result.add(resultSet.getString("table_name"));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/SQLServerSchemaMetaDataLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/SQLServerSchemaMetaDataLoader.java
index 0e1cc827a94..76d1aab47e5 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/SQLServerSchemaMetaDataLoader.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/SQLServerSchemaMetaDataLoader.java
@@ -74,8 +74,9 @@ public final class SQLServerSchemaMetaDataLoader implements DialectSchemaMetaDat
private Map<String, Collection<ColumnMetaData>> loadColumnMetaDataMap(final DataSource dataSource, final Collection<String> tables) throws SQLException {
Map<String, Collection<ColumnMetaData>> result = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getTableMetaDataSQL(tables))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getTableMetaDataSQL(tables))) {
Map<String, Integer> dataTypes = DataTypeLoader.load(connection.getMetaData());
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
@@ -108,8 +109,9 @@ public final class SQLServerSchemaMetaDataLoader implements DialectSchemaMetaDat
private Map<String, Collection<IndexMetaData>> loadIndexMetaData(final DataSource dataSource, final Collection<String> tableNames) throws SQLException {
Map<String, Collection<IndexMetaData>> result = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getIndexMetaDataSQL(tableNames))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getIndexMetaDataSQL(tableNames))) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
String indexName = resultSet.getString("INDEX_NAME");
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngine.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngine.java
index b6f16ba1513..33235c0ba19 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngine.java
@@ -50,8 +50,9 @@ public final class YamlEngine {
* @throws IOException IO Exception
*/
public static <T extends YamlConfiguration> T unmarshal(final File yamlFile, final Class<T> classType) throws IOException {
- try (FileInputStream fileInputStream = new FileInputStream(yamlFile);
- InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)) {
+ try (
+ FileInputStream fileInputStream = new FileInputStream(yamlFile);
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)) {
return new Yaml(new ShardingSphereYamlConstructor(classType)).loadAs(inputStreamReader, classType);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngineTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngineTest.java
index 199cc7223ec..45d139745b3 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngineTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngineTest.java
@@ -49,8 +49,9 @@ public final class YamlEngineTest {
URL url = getClass().getClassLoader().getResource("yaml/fixture-rule.yaml");
assertNotNull(url);
StringBuilder yamlContent = new StringBuilder();
- try (FileReader fileReader = new FileReader(url.getFile());
- BufferedReader reader = new BufferedReader(fileReader)) {
+ try (
+ FileReader fileReader = new FileReader(url.getFile());
+ BufferedReader reader = new BufferedReader(fileReader)) {
String line;
while (null != (line = reader.readLine())) {
yamlContent.append(line).append(System.lineSeparator());
@@ -90,8 +91,9 @@ public final class YamlEngineTest {
URL url = getClass().getClassLoader().getResource("yaml/accepted-class.yaml");
assertNotNull(url);
StringBuilder yamlContent = new StringBuilder();
- try (FileReader fileReader = new FileReader(url.getFile());
- BufferedReader reader = new BufferedReader(fileReader)) {
+ try (
+ FileReader fileReader = new FileReader(url.getFile());
+ BufferedReader reader = new BufferedReader(fileReader)) {
String line;
while (null != (line = reader.readLine())) {
yamlContent.append(line).append(System.lineSeparator());
diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
index 6b4154fdfdc..2e5c2d50d95 100644
--- a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
@@ -46,8 +46,9 @@ public final class DatabaseDatetimeService implements DatetimeService {
}
private Date loadDatetime(final DataSource dataSource, final String datetimeLoadingSQL) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(datetimeLoadingSQL)) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(datetimeLoadingSQL)) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
return (Date) resultSet.getObject(1);
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/segment/projection/impl/AggregationProjectionConverter.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/segment/projection/impl/AggregationProjectionConverter.java
index ae03af7ef56..e3e72abf9a1 100644
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/segment/projection/impl/AggregationProjectionConverter.java
+++ b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/segment/projection/impl/AggregationProjectionConverter.java
@@ -78,7 +78,7 @@ public final class AggregationProjectionConverter implements SQLSegmentConverter
if (segment.getAlias().isPresent()) {
return Optional.of(new SqlBasicCall(SqlStdOperatorTable.AS, new SqlNode[]{new SqlBasicCall(convertOperator(segment.getType().name()),
new SqlNode[]{createParametersSqlNode(parameters)}, SqlParserPos.ZERO, false, functionQuantifier),
- SqlIdentifier.star(Collections.singletonList(segment.getAlias().get()), SqlParserPos.ZERO, Collections.singletonList(SqlParserPos.ZERO))}, SqlParserPos.ZERO));
+ SqlIdentifier.star(Collections.singletonList(segment.getAlias().get()), SqlParserPos.ZERO, Collections.singletonList(SqlParserPos.ZERO))}, SqlParserPos.ZERO));
}
return Optional.of(new SqlBasicCall(convertOperator(segment.getType().name()),
new SqlNode[]{createParametersSqlNode(parameters)}, SqlParserPos.ZERO, false, functionQuantifier));
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/segment/projection/impl/ExpressionProjectionConverter.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/segment/projection/impl/ExpressionProjectionConverter.java
index 515b73af3ab..443bc173bd9 100644
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/segment/projection/impl/ExpressionProjectionConverter.java
+++ b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/segment/projection/impl/ExpressionProjectionConverter.java
@@ -48,7 +48,7 @@ public final class ExpressionProjectionConverter implements SQLSegmentConverter<
Optional<SqlNode> exprSqlNode = new ExpressionConverter().convertToSQLNode(segment.getExpr());
if (exprSqlNode.isPresent() && segment.getAlias().isPresent()) {
return Optional.of(new SqlBasicCall(SqlStdOperatorTable.AS, new SqlNode[]{exprSqlNode.get(),
- SqlIdentifier.star(Collections.singletonList(segment.getAlias().get()), SqlParserPos.ZERO, Collections.singletonList(SqlParserPos.ZERO))}, SqlParserPos.ZERO));
+ SqlIdentifier.star(Collections.singletonList(segment.getAlias().get()), SqlParserPos.ZERO, Collections.singletonList(SqlParserPos.ZERO))}, SqlParserPos.ZERO));
}
return exprSqlNode;
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/EncryptResultSetTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/EncryptResultSetTest.java
index 13479702139..5e97202e0a6 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/EncryptResultSetTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/EncryptResultSetTest.java
@@ -36,8 +36,9 @@ public final class EncryptResultSetTest extends AbstractShardingSphereDataSource
@Test
public void assertResultSetIsBeforeFirst() throws SQLException {
- try (Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
+ try (
+ Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
assertTrue(resultSet.isBeforeFirst());
resultSet.next();
assertThat(resultSet.getRow(), is(1));
@@ -50,8 +51,9 @@ public final class EncryptResultSetTest extends AbstractShardingSphereDataSource
@Test
public void assertResultSetGetRow() throws SQLException {
- try (Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
+ try (
+ Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
resultSet.next();
assertThat(resultSet.getRow(), is(1));
}
@@ -59,8 +61,9 @@ public final class EncryptResultSetTest extends AbstractShardingSphereDataSource
@Test
public void assertResultSetAfterLast() throws SQLException {
- try (Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
+ try (
+ Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
resultSet.afterLast();
assertTrue(resultSet.isAfterLast());
}
@@ -68,16 +71,18 @@ public final class EncryptResultSetTest extends AbstractShardingSphereDataSource
@Test
public void assertResultSetBeforeFirst() throws SQLException {
- try (Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
+ try (
+ Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
assertTrue(resultSet.isBeforeFirst());
}
}
@Test
public void assertResultSetPrevious() throws SQLException {
- try (Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
+ try (
+ Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
resultSet.next();
assertThat(resultSet.getRow(), is(1));
resultSet.previous();
@@ -87,8 +92,9 @@ public final class EncryptResultSetTest extends AbstractShardingSphereDataSource
@Test
public void assertRelative() throws SQLException {
- try (Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
+ try (
+ Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
resultSet.next();
resultSet.relative(1);
assertThat(resultSet.getRow(), is(2));
@@ -97,8 +103,9 @@ public final class EncryptResultSetTest extends AbstractShardingSphereDataSource
@Test
public void assertAbsolute() throws SQLException {
- try (Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
+ try (
+ Statement statement = getEncryptConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet resultSet = statement.executeQuery(SELECT_SQL_TO_ASSERT)) {
resultSet.absolute(2);
assertThat(resultSet.getRow(), is(2));
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptPreparedStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptPreparedStatementTest.java
index 76421871407..1ef54fd66c8 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptPreparedStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptPreparedStatementTest.java
@@ -181,8 +181,9 @@ public final class EncryptPreparedStatementTest extends AbstractShardingSphereDa
}
private void assertResultSet(final int resultSetCount, final int id, final Object pwd, final Object assistPwd) throws SQLException {
- try (Connection conn = getActualDataSources().get("encrypt").getConnection();
- Statement stmt = conn.createStatement()) {
+ try (
+ Connection conn = getActualDataSources().get("encrypt").getConnection();
+ Statement stmt = conn.createStatement()) {
ResultSet resultSet = stmt.executeQuery(SELECT_ALL_SQL);
int count = 1;
while (resultSet.next()) {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptStatementTest.java
index 9c2acca41ae..7c10b8cd629 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptStatementTest.java
@@ -167,8 +167,9 @@ public final class EncryptStatementTest extends AbstractShardingSphereDataSource
}
private void assertResultSet(final int resultSetCount, final int id, final Object pwd, final Object plain) throws SQLException {
- try (Connection conn = getActualDataSources().get("encrypt").getConnection();
- Statement stmt = conn.createStatement()) {
+ try (
+ Connection conn = getActualDataSources().get("encrypt").getConnection();
+ Statement stmt = conn.createStatement()) {
ResultSet resultSet = stmt.executeQuery(SELECT_SQL_TO_ASSERT);
int count = 1;
while (resultSet.next()) {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ReadwriteSplittingPreparedStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ReadwriteSplittingPreparedStatementTest.java
index fe04e8fee51..8025b0bcb9a 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ReadwriteSplittingPreparedStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ReadwriteSplittingPreparedStatementTest.java
@@ -56,8 +56,9 @@ public final class ReadwriteSplittingPreparedStatementTest extends AbstractShard
@Test
public void assertGetGeneratedKeys() throws SQLException {
- try (PreparedStatement preparedStatement = getReadwriteSplittingDataSource()
- .getConnection().prepareStatement("INSERT INTO t_config(status) VALUES(?);", Statement.RETURN_GENERATED_KEYS)) {
+ try (
+ PreparedStatement preparedStatement = getReadwriteSplittingDataSource()
+ .getConnection().prepareStatement("INSERT INTO t_config(status) VALUES(?);", Statement.RETURN_GENERATED_KEYS)) {
preparedStatement.setString(1, "OK");
preparedStatement.executeUpdate();
ResultSet generatedKeys = preparedStatement.getGeneratedKeys();
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java
index b8a522cf7e9..60a2ee73c0b 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java
@@ -73,8 +73,9 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertExecuteBatchWithoutAddBatch() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL)) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL)) {
int[] actual = preparedStatement.executeBatch();
assertThat(actual, is(new int[0]));
}
@@ -82,8 +83,9 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertAddBatch() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL)) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL)) {
preparedStatement.setInt(1, 3101);
preparedStatement.setInt(2, 11);
preparedStatement.setInt(3, 11);
@@ -113,9 +115,10 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertMultiValuesWithGenerateShardingKeyColumn() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_MULTI_VALUES_WITH_GENERATE_SHARDING_KEY_SQL, Statement.RETURN_GENERATED_KEYS);
- Statement queryStatement = connection.createStatement()) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_MULTI_VALUES_WITH_GENERATE_SHARDING_KEY_SQL, Statement.RETURN_GENERATED_KEYS);
+ Statement queryStatement = connection.createStatement()) {
ResetIncrementKeyGenerateAlgorithm.getCOUNT().set(0);
preparedStatement.setString(1, "BATCH1");
preparedStatement.setString(2, "BATCH2");
@@ -154,9 +157,10 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertAddBatchMultiValuesWithGenerateShardingKeyColumn() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_MULTI_VALUES_WITH_GENERATE_SHARDING_KEY_SQL, Statement.RETURN_GENERATED_KEYS);
- Statement queryStatement = connection.createStatement()) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_MULTI_VALUES_WITH_GENERATE_SHARDING_KEY_SQL, Statement.RETURN_GENERATED_KEYS);
+ Statement queryStatement = connection.createStatement()) {
ResetIncrementKeyGenerateAlgorithm.getCOUNT().set(10);
preparedStatement.setString(1, "BATCH1");
preparedStatement.setString(2, "BATCH2");
@@ -227,9 +231,10 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertAddBatchWithoutGenerateKeyColumn() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITHOUT_GENERATE_KEY_SQL, Statement.RETURN_GENERATED_KEYS);
- Statement queryStatement = connection.createStatement()) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITHOUT_GENERATE_KEY_SQL, Statement.RETURN_GENERATED_KEYS);
+ Statement queryStatement = connection.createStatement()) {
preparedStatement.setInt(1, 11);
preparedStatement.setInt(2, 11);
preparedStatement.setString(3, "BATCH");
@@ -281,9 +286,10 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertAddBatchWithGenerateKeyColumn() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL, Statement.RETURN_GENERATED_KEYS);
- Statement queryStatement = connection.createStatement()) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL, Statement.RETURN_GENERATED_KEYS);
+ Statement queryStatement = connection.createStatement()) {
preparedStatement.setInt(1, 1);
preparedStatement.setInt(2, 11);
preparedStatement.setInt(3, 11);
@@ -339,8 +345,9 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertGeneratedKeysForBatchInsert() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL_WITH_MULTI_VALUES, Statement.RETURN_GENERATED_KEYS)) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL_WITH_MULTI_VALUES, Statement.RETURN_GENERATED_KEYS)) {
preparedStatement.setInt(1, 11);
preparedStatement.setInt(2, 11);
preparedStatement.setString(3, "MULTI");
@@ -359,8 +366,9 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertAddGetGeneratedKeysForNoGeneratedValues() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_NO_SHARDING_SQL, Statement.RETURN_GENERATED_KEYS)) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_NO_SHARDING_SQL, Statement.RETURN_GENERATED_KEYS)) {
preparedStatement.setString(1, "show");
preparedStatement.setString(2, "yes");
preparedStatement.execute();
@@ -378,9 +386,10 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
int orderId = 200;
String status = "init";
String updatedStatus = "updated on duplicate key";
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_ON_DUPLICATE_KEY_SQL);
- PreparedStatement queryStatement = connection.prepareStatement(SELECT_SQL_WITH_PARAMETER_MARKER_RETURN_STATUS)) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_ON_DUPLICATE_KEY_SQL);
+ PreparedStatement queryStatement = connection.prepareStatement(SELECT_SQL_WITH_PARAMETER_MARKER_RETURN_STATUS)) {
preparedStatement.setInt(1, itemId);
preparedStatement.setInt(2, orderId);
preparedStatement.setInt(3, userId1);
@@ -408,9 +417,10 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
}
}
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_ON_DUPLICATE_KEY_SQL);
- PreparedStatement queryStatement = connection.prepareStatement(SELECT_SQL_WITH_PARAMETER_MARKER_RETURN_STATUS)) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_ON_DUPLICATE_KEY_SQL);
+ PreparedStatement queryStatement = connection.prepareStatement(SELECT_SQL_WITH_PARAMETER_MARKER_RETURN_STATUS)) {
preparedStatement.setInt(1, itemId);
preparedStatement.setInt(2, orderId);
preparedStatement.setInt(3, userId1);
@@ -441,8 +451,9 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertUpdateBatch() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_BATCH_SQL)) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_BATCH_SQL)) {
preparedStatement.setString(1, "batch");
preparedStatement.setString(2, "init");
preparedStatement.addBatch();
@@ -533,8 +544,9 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
@Test
public void assertClearBatch() throws SQLException {
- try (Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL)) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_WITH_GENERATE_KEY_SQL)) {
preparedStatement.setInt(1, 3101);
preparedStatement.setInt(2, 11);
preparedStatement.setInt(3, 11);
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java
index 94b667f986f..ef4e9fe14f5 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java
@@ -37,8 +37,9 @@ public final class ShardingSphereStatementTest extends AbstractShardingSphereDat
@Test
public void assertGetGeneratedKeys() throws SQLException {
String sql = "INSERT INTO t_order_item(order_id, user_id, status) VALUES (%d, %d, '%s')";
- try (Connection connection = getShardingSphereDataSource().getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = getShardingSphereDataSource().getConnection();
+ Statement statement = connection.createStatement()) {
assertFalse(statement.execute(String.format(sql, 1, 1, "init")));
assertFalse(statement.execute(String.format(sql, 1, 1, "init"), Statement.NO_GENERATED_KEYS));
assertFalse(statement.execute(String.format(sql, 1, 1, "init"), Statement.RETURN_GENERATED_KEYS));
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/MySQLPrivilegeHandler.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/MySQLPrivilegeHandler.java
index fa27d890986..29db1f72891 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/MySQLPrivilegeHandler.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/MySQLPrivilegeHandler.java
@@ -56,9 +56,10 @@ public final class MySQLPrivilegeHandler implements StoragePrivilegeHandler {
@Override
public Collection<ShardingSphereUser> diff(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
Collection<Grantee> grantees = new LinkedList<>();
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getGlobalPrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getGlobalPrivilegesSQL(users))) {
while (resultSet.next()) {
grantees.add(new Grantee(resultSet.getString("user"), resultSet.getString("host")));
}
@@ -104,9 +105,10 @@ public final class MySQLPrivilegeHandler implements StoragePrivilegeHandler {
private void fillGlobalPrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getGlobalPrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getGlobalPrivilegesSQL(users))) {
while (resultSet.next()) {
fillGlobalPrivileges(userPrivilegeMap, resultSet);
}
@@ -123,9 +125,10 @@ public final class MySQLPrivilegeHandler implements StoragePrivilegeHandler {
private void fillSchemaPrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSchemaPrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getSchemaPrivilegesSQL(users))) {
while (resultSet.next()) {
fillSchemaPrivileges(userPrivilegeMap, resultSet);
}
@@ -144,9 +147,10 @@ public final class MySQLPrivilegeHandler implements StoragePrivilegeHandler {
private void fillTablePrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getTablePrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getTablePrivilegesSQL(users))) {
while (resultSet.next()) {
fillTablePrivileges(userPrivilegeMap, resultSet);
}
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandler.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandler.java
index c103d774476..0f4e6847110 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandler.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandler.java
@@ -57,9 +57,10 @@ public final class OraclePrivilegeHandler implements StoragePrivilegeHandler {
@Override
public Collection<ShardingSphereUser> diff(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
Collection<Grantee> grantees = new LinkedList<>();
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSysPrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getSysPrivilegesSQL(users))) {
while (resultSet.next()) {
grantees.add(new Grantee(resultSet.getString("GRANTEE"), ""));
}
@@ -97,9 +98,10 @@ public final class OraclePrivilegeHandler implements StoragePrivilegeHandler {
private void fillTablePrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap, final DataSource dataSource,
final Collection<ShardingSphereUser> users) throws SQLException {
Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getTablePrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getTablePrivilegesSQL(users))) {
while (resultSet.next()) {
collectTablePrivileges(privilegeCache, resultSet);
}
@@ -141,9 +143,10 @@ public final class OraclePrivilegeHandler implements StoragePrivilegeHandler {
private void fillSysPrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap, final DataSource dataSource,
final Collection<ShardingSphereUser> users) throws SQLException {
Map<ShardingSphereUser, List<PrivilegeType>> privilegeCache = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSysPrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getSysPrivilegesSQL(users))) {
while (resultSet.next()) {
collectSysPrivileges(privilegeCache, resultSet);
}
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandler.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandler.java
index c55ec80ea05..9d010646db8 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandler.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandler.java
@@ -57,9 +57,10 @@ public final class PostgreSQLPrivilegeHandler implements StoragePrivilegeHandler
@Override
public Collection<ShardingSphereUser> diff(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
Collection<Grantee> grantees = new LinkedList<>();
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getRolePrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getRolePrivilegesSQL(users))) {
while (resultSet.next()) {
grantees.add(new Grantee(resultSet.getString("rolname"), ""));
}
@@ -105,9 +106,10 @@ public final class PostgreSQLPrivilegeHandler implements StoragePrivilegeHandler
private void fillTablePrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getTablePrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getTablePrivilegesSQL(users))) {
while (resultSet.next()) {
collectPrivileges(privilegeCache, resultSet);
}
@@ -148,9 +150,10 @@ public final class PostgreSQLPrivilegeHandler implements StoragePrivilegeHandler
private void fillRolePrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getRolePrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getRolePrivilegesSQL(users))) {
while (resultSet.next()) {
fillRolePrivileges(userPrivilegeMap, resultSet);
}
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/SQLServerPrivilegeHandler.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/SQLServerPrivilegeHandler.java
index f4d0cd56bd7..700821d4031 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/SQLServerPrivilegeHandler.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/SQLServerPrivilegeHandler.java
@@ -75,9 +75,10 @@ public final class SQLServerPrivilegeHandler implements StoragePrivilegeHandler
@Override
public Collection<ShardingSphereUser> diff(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
Collection<Grantee> grantees = new LinkedList<>();
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getGlobalPrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getGlobalPrivilegesSQL(users))) {
while (resultSet.next()) {
grantees.add(new Grantee(resultSet.getString("GRANTEE"), ""));
}
@@ -136,9 +137,10 @@ public final class SQLServerPrivilegeHandler implements StoragePrivilegeHandler
private void fillGlobalPrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getGlobalPrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getGlobalPrivilegesSQL(users))) {
while (resultSet.next()) {
fillGlobalPrivileges(userPrivilegeMap, resultSet);
}
@@ -153,9 +155,10 @@ public final class SQLServerPrivilegeHandler implements StoragePrivilegeHandler
}
private void fillSchemaPrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap, final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSchemaPrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getSchemaPrivilegesSQL(users))) {
while (resultSet.next()) {
fillSchemaPrivileges(userPrivilegeMap, resultSet);
}
@@ -174,9 +177,10 @@ public final class SQLServerPrivilegeHandler implements StoragePrivilegeHandler
private void fillTablePrivileges(final Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap, final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache = new HashMap<>();
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getTablePrivilegesSQL(users))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getTablePrivilegesSQL(users))) {
while (resultSet.next()) {
collectPrivileges(privilegeCache, resultSet);
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyChecker.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyChecker.java
index b51740ce096..da777fab1ff 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyChecker.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyChecker.java
@@ -103,8 +103,9 @@ public final class DataConsistencyChecker {
PipelineDataSourceConfiguration targetDataSourceConfig = PipelineDataSourceConfigurationFactory.newInstance(
jobConfig.getPipelineConfig().getTarget().getType(), jobConfig.getPipelineConfig().getTarget().getParameter());
Map<String, DataConsistencyCountCheckResult> result = new LinkedHashMap<>(logicTableNames.size(), 1);
- try (PipelineDataSourceWrapper sourceDataSource = PipelineDataSourceFactory.newInstance(sourceDataSourceConfig);
- PipelineDataSourceWrapper targetDataSource = PipelineDataSourceFactory.newInstance(targetDataSourceConfig)) {
+ try (
+ PipelineDataSourceWrapper sourceDataSource = PipelineDataSourceFactory.newInstance(sourceDataSourceConfig);
+ PipelineDataSourceWrapper targetDataSource = PipelineDataSourceFactory.newInstance(targetDataSourceConfig)) {
for (String each : logicTableNames) {
result.put(each, checkCount(each, sourceDataSource, targetDataSource, executor));
}
@@ -131,9 +132,10 @@ public final class DataConsistencyChecker {
}
private long count(final DataSource dataSource, final String table, final DatabaseType databaseType) {
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(PipelineSQLBuilderFactory.newInstance(databaseType.getName()).buildCountSQL(table));
- ResultSet resultSet = preparedStatement.executeQuery()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(PipelineSQLBuilderFactory.newInstance(databaseType.getName()).buildCountSQL(table));
+ ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
return resultSet.getLong(1);
} catch (final SQLException ex) {
@@ -148,8 +150,9 @@ public final class DataConsistencyChecker {
ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 2, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(2), threadFactory);
JobRateLimitAlgorithm inputRateLimitAlgorithm = RuleAlteredJobWorker.createRuleAlteredContext(jobConfig).getInputRateLimitAlgorithm();
Map<String, DataConsistencyContentCheckResult> result = new HashMap<>(logicTableNames.size(), 1);
- try (PipelineDataSourceWrapper sourceDataSource = PipelineDataSourceFactory.newInstance(sourceDataSourceConfig);
- PipelineDataSourceWrapper targetDataSource = PipelineDataSourceFactory.newInstance(targetDataSourceConfig)) {
+ try (
+ PipelineDataSourceWrapper sourceDataSource = PipelineDataSourceFactory.newInstance(sourceDataSourceConfig);
+ PipelineDataSourceWrapper targetDataSource = PipelineDataSourceFactory.newInstance(targetDataSourceConfig)) {
Map<String, TableMetaData> tableMetaDataMap = getTableMetaDataMap(jobConfig.getWorkflowConfig().getSchemaName());
logicTableNames.forEach(each -> {
// TODO put to preparer
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/CRC32MatchDataConsistencyCalculateAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/CRC32MatchDataConsistencyCalculateAlgorithm.java
index 0adf19036aa..138ae72db21 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/CRC32MatchDataConsistencyCalculateAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/CRC32MatchDataConsistencyCalculateAlgorithm.java
@@ -65,9 +65,10 @@ public final class CRC32MatchDataConsistencyCalculateAlgorithm implements DataCo
}
private long calculateCRC32(final DataSource dataSource, final String sql) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- ResultSet resultSet = preparedStatement.executeQuery()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
return resultSet.getLong(1);
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
index eb97fda2d42..dce36b57c3f 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
@@ -92,8 +92,9 @@ public final class DataMatchDataConsistencyCalculateAlgorithm extends AbstractSt
}
private Optional<Object> query(final DataSource dataSource, final String sql, final String uniqueKey, final Number startUniqueKeyValue, final int chunkSize) throws SQLException {
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
preparedStatement.setObject(1, startUniqueKeyValue);
preparedStatement.setInt(2, chunkSize);
Collection<Collection<Object>> records = new ArrayList<>(chunkSize);
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/datasource/AbstractDataSourceChecker.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/datasource/AbstractDataSourceChecker.java
index 5fc4191846d..bdb2f718990 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/datasource/AbstractDataSourceChecker.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/datasource/AbstractDataSourceChecker.java
@@ -59,9 +59,10 @@ public abstract class AbstractDataSourceChecker implements DataSourceChecker {
private void checkEmpty(final DataSource dataSource, final Collection<String> tableNames) throws SQLException {
for (String each : tableNames) {
String sql = getSQLBuilder().buildCheckEmptySQL(each);
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- ResultSet resultSet = preparedStatement.executeQuery()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
if (resultSet.next()) {
throw new PipelineJobPrepareFailedException(String.format("Target table `%s` is not empty, sql: %s.", each, sql));
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/prepare/InventoryTaskSplitter.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/prepare/InventoryTaskSplitter.java
index cfda6f7a9d0..851749b0189 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/prepare/InventoryTaskSplitter.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/prepare/InventoryTaskSplitter.java
@@ -180,8 +180,9 @@ public final class InventoryTaskSplitter {
JobConfiguration jobConfig = jobContext.getJobConfig();
String sql = PipelineSQLBuilderFactory.newInstance(jobConfig.getHandleConfig().getSourceDatabaseType())
.buildSplitByPrimaryKeyRangeSQL(dumperConfig.getTableName(), dumperConfig.getPrimaryKey());
- try (Connection connection = dataSource.getConnection();
- PreparedStatement ps = connection.prepareStatement(sql)) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement ps = connection.prepareStatement(sql)) {
long beginId = 0;
for (int i = 0; i < Integer.MAX_VALUE; i++) {
ps.setLong(1, beginId);
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/scaling/core/job/environment/ScalingEnvironmentManager.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/scaling/core/job/environment/ScalingEnvironmentManager.java
index 772ba8e478b..f01419f6db0 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/scaling/core/job/environment/ScalingEnvironmentManager.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/scaling/core/job/environment/ScalingEnvironmentManager.java
@@ -47,8 +47,9 @@ public final class ScalingEnvironmentManager {
Collection<String> tables = jobConfig.getHandleConfig().splitLogicTableNames();
log.info("cleanupTargetTables, tables={}", tables);
YamlPipelineDataSourceConfiguration target = jobConfig.getPipelineConfig().getTarget();
- try (PipelineDataSourceWrapper dataSource = PipelineDataSourceFactory.newInstance(PipelineDataSourceConfigurationFactory.newInstance(target.getType(), target.getParameter()));
- Connection connection = dataSource.getConnection()) {
+ try (
+ PipelineDataSourceWrapper dataSource = PipelineDataSourceFactory.newInstance(PipelineDataSourceConfigurationFactory.newInstance(target.getType(), target.getParameter()));
+ Connection connection = dataSource.getConnection()) {
for (String each : tables) {
String sql = PipelineSQLBuilderFactory.newInstance(jobConfig.getHandleConfig().getTargetDatabaseType()).buildTruncateSQL(each);
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/check/datasource/MySQLDataSourceChecker.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/check/datasource/MySQLDataSourceChecker.java
index de7ca5ee8f6..1129940e2fe 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/check/datasource/MySQLDataSourceChecker.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/check/datasource/MySQLDataSourceChecker.java
@@ -60,9 +60,10 @@ public final class MySQLDataSourceChecker extends AbstractDataSourceChecker {
}
private void checkPrivilege(final DataSource dataSource) {
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(SHOW_GRANTS_SQL);
- ResultSet resultSet = preparedStatement.executeQuery()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(SHOW_GRANTS_SQL);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
String privilege = resultSet.getString(1).toUpperCase();
if (matchPrivileges(privilege)) {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLPositionInitializer.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLPositionInitializer.java
index 766d7dc1312..637afcd625e 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLPositionInitializer.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLPositionInitializer.java
@@ -49,16 +49,18 @@ public final class MySQLPositionInitializer implements PositionInitializer {
}
private BinlogPosition getBinlogPosition(final Connection connection) throws SQLException {
- try (PreparedStatement preparedStatement = connection.prepareStatement("SHOW MASTER STATUS");
- ResultSet resultSet = preparedStatement.executeQuery()) {
+ try (
+ PreparedStatement preparedStatement = connection.prepareStatement("SHOW MASTER STATUS");
+ ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
return new BinlogPosition(resultSet.getString(1), resultSet.getLong(2));
}
}
private long getServerId(final Connection connection) throws SQLException {
- try (PreparedStatement preparedStatement = connection.prepareStatement("SHOW VARIABLES LIKE 'server_id'");
- ResultSet resultSet = preparedStatement.executeQuery()) {
+ try (
+ PreparedStatement preparedStatement = connection.prepareStatement("SHOW VARIABLES LIKE 'server_id'");
+ ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
return resultSet.getLong(2);
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparer.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparer.java
index 75d9ddcae36..0657f5fb720 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparer.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparer.java
@@ -46,8 +46,9 @@ public final class MySQLDataSourcePreparer extends AbstractDataSourcePreparer {
public void prepareTargetTables(final PrepareTargetTablesParameter parameter) {
PipelineConfiguration pipelineConfig = parameter.getPipelineConfiguration();
PipelineDataSourceManager dataSourceManager = parameter.getDataSourceManager();
- try (Connection sourceConnection = getSourceCachedDataSource(pipelineConfig, dataSourceManager).getConnection();
- Connection targetConnection = getTargetCachedDataSource(pipelineConfig, dataSourceManager).getConnection()) {
+ try (
+ Connection sourceConnection = getSourceCachedDataSource(pipelineConfig, dataSourceManager).getConnection();
+ Connection targetConnection = getTargetCachedDataSource(pipelineConfig, dataSourceManager).getConnection()) {
Collection<String> logicTableNames = parameter.getTablesFirstDataNodes().getEntries().stream().map(JobDataNodeEntry::getLogicTableName).collect(Collectors.toList());
for (String each : logicTableNames) {
String createTableSQL = getCreateTableSQL(sourceConnection, each);
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumperTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumperTest.java
index 66fe0ff9247..503d1d74a4c 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumperTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumperTest.java
@@ -81,8 +81,9 @@ public final class MySQLIncrementalDumperTest {
@SneakyThrows(SQLException.class)
private void initTableData(final DumperConfiguration dumperConfig) {
DataSource dataSource = new PipelineDataSourceManager().getDataSource(dumperConfig.getDataSourceConfig());
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLJdbcDumperTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLJdbcDumperTest.java
index 0ebed3b1e56..9c894e04c9c 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLJdbcDumperTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLJdbcDumperTest.java
@@ -73,8 +73,9 @@ public final class MySQLJdbcDumperTest {
@SneakyThrows(SQLException.class)
private void initTableData(final DataSource dataSource) {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussPositionInitializer.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussPositionInitializer.java
index 086dd9e7def..e30e6d844ce 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussPositionInitializer.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussPositionInitializer.java
@@ -92,8 +92,9 @@ public final class OpenGaussPositionInitializer implements PositionInitializer {
}
private WalPosition getWalPosition(final Connection connection) throws SQLException {
- try (PreparedStatement preparedStatement = connection.prepareStatement("SELECT PG_CURRENT_XLOG_LOCATION()");
- ResultSet resultSet = preparedStatement.executeQuery()) {
+ try (
+ PreparedStatement preparedStatement = connection.prepareStatement("SELECT PG_CURRENT_XLOG_LOCATION()");
+ ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
return new WalPosition(new OpenGaussLogSequenceNumber(LogSequenceNumber.valueOf(resultSet.getString(1))));
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPluginTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPluginTest.java
index 0a1b4a32a22..035a90bf1ff 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPluginTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPluginTest.java
@@ -135,10 +135,10 @@ public final class MppdbDecodingPluginTest {
tableData.setTableName("public.test");
tableData.setOpType("INSERT");
String[] insertTypes = new String[]{
- "time without time zone", "time with time zone", "timestamp without time zone", "timestamp with time zone", "smalldatetime", "date", "interval", "reltime"};
+ "time without time zone", "time with time zone", "timestamp without time zone", "timestamp with time zone", "smalldatetime", "date", "interval", "reltime"};
String[] insertValues = new String[]{"'21:21:21'", "'21:21:21 pst'", "'2010-12-12'", "'2013-12-11 pst'", "'2003-04-12 04:05:06'", "'2021-10-10'", "'3 days'", "'2 mons'"};
final String[] compareValues = {
- "21:21:21", "13:21:21", "2010-12-12 00:00:00.0", "2013-12-11 16:00:00.0", "2003-04-12 04:05:00.0", "2021-10-10", "0 years 0 mons 3 days 0 hours 0 mins 0.00 secs", "2 mons"};
+ "21:21:21", "13:21:21", "2010-12-12 00:00:00.0", "2013-12-11 16:00:00.0", "2003-04-12 04:05:00.0", "2021-10-10", "0 years 0 mons 3 days 0 hours 0 mins 0.00 secs", "2 mons"};
tableData.setColumnsName(IntStream.range(0, insertTypes.length).mapToObj(idx -> "data" + idx).toArray(String[]::new));
tableData.setColumnsType(insertTypes);
tableData.setColumnsVal(insertValues);
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLPositionInitializer.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLPositionInitializer.java
index 606198c049e..34275e4aef4 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLPositionInitializer.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLPositionInitializer.java
@@ -81,8 +81,9 @@ public final class PostgreSQLPositionInitializer implements PositionInitializer
}
private WalPosition getWalPosition(final Connection connection) throws SQLException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getLogSequenceNumberSQL(connection));
- ResultSet resultSet = preparedStatement.executeQuery()) {
+ try (
+ PreparedStatement preparedStatement = connection.prepareStatement(getLogSequenceNumberSQL(connection));
+ ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
return new WalPosition(new PostgreSQLLogSequenceNumber(LogSequenceNumber.valueOf(resultSet.getString(1))));
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWalDumper.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWalDumper.java
index 0f65746e28c..c844cb063d6 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWalDumper.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWalDumper.java
@@ -77,8 +77,9 @@ public final class PostgreSQLWalDumper extends AbstractIncrementalDumper<WalPosi
private void dump() {
// TODO use unified PgConnection
- try (Connection connection = logicalReplication.createConnection((StandardPipelineDataSourceConfiguration) dumperConfig.getDataSourceConfig());
- PGReplicationStream stream = logicalReplication.createReplicationStream(connection, PostgreSQLPositionInitializer.getUniqueSlotName(connection), walPosition.getLogSequenceNumber())) {
+ try (
+ Connection connection = logicalReplication.createConnection((StandardPipelineDataSourceConfiguration) dumperConfig.getDataSourceConfig());
+ PGReplicationStream stream = logicalReplication.createReplicationStream(connection, PostgreSQLPositionInitializer.getUniqueSlotName(connection), walPosition.getLogSequenceNumber())) {
PostgreSQLTimestampUtils utils = new PostgreSQLTimestampUtils(connection.unwrap(PgConnection.class).getTimestampUtils());
DecodingPlugin decodingPlugin = new TestDecodingPlugin(utils);
while (isRunning()) {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePreparer.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSource [...]
index 8708b3ba82b..8c55316f395 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePreparer.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePreparer.java
@@ -84,8 +84,9 @@ public final class PostgreSQLDataSourcePreparer extends AbstractDataSourcePrepar
}
Map<String, Collection<String>> createLogicTableSQLs = getCreateLogicTableSQLs(actualTableDefinitions);
- try (Connection targetConnection = getTargetCachedDataSource(parameter.getPipelineConfiguration(),
- parameter.getDataSourceManager()).getConnection()) {
+ try (
+ Connection targetConnection = getTargetCachedDataSource(parameter.getPipelineConfiguration(),
+ parameter.getDataSourceManager()).getConnection()) {
for (Entry<String, Collection<String>> entry : createLogicTableSQLs.entrySet()) {
for (String each : entry.getValue()) {
executeTargetTableSQL(targetConnection, each);
@@ -152,8 +153,9 @@ public final class PostgreSQLDataSourcePreparer extends AbstractDataSourcePrepar
private Pair<String, List<String>> queryTablePrimaryKey(final Connection sourceConnection, final String actualTableName) throws SQLException {
String primaryKeyName = null;
List<String> primaryKeyColumns = new LinkedList<>();
- try (Statement statement = sourceConnection.createStatement();
- ResultSet resultSet = statement.executeQuery(String.format(FETCH_PRIMARY_KEY_TEMPLATE, actualTableName))) {
+ try (
+ Statement statement = sourceConnection.createStatement();
+ ResultSet resultSet = statement.executeQuery(String.format(FETCH_PRIMARY_KEY_TEMPLATE, actualTableName))) {
while (resultSet.next()) {
primaryKeyName = primaryKeyName == null ? resultSet.getString(1) : primaryKeyName;
primaryKeyColumns.add(resultSet.getString(2));
@@ -177,8 +179,9 @@ public final class PostgreSQLDataSourcePreparer extends AbstractDataSourcePrepar
private List<String> queryCreateIndexes(final Connection sourceConnection, final String actualTableName, final String pkName) throws SQLException {
List<String> result = new LinkedList<>();
- try (Statement statement = sourceConnection.createStatement();
- ResultSet resultSet = statement.executeQuery(String.format(FETCH_NORMAL_INDEXES_TEMPLATE, actualTableName, pkName))) {
+ try (
+ Statement statement = sourceConnection.createStatement();
+ ResultSet resultSet = statement.executeQuery(String.format(FETCH_NORMAL_INDEXES_TEMPLATE, actualTableName, pkName))) {
while (resultSet.next()) {
// TODO add drop index first, make sure the index is not exist
result.add(String.format(DROP_INDEX_TEMPLATE, resultSet.getString(1), resultSet.getString(2)));
@@ -192,8 +195,9 @@ public final class PostgreSQLDataSourcePreparer extends AbstractDataSourcePrepar
final String fetchCommentSql = String.format(FETCH_COMMENT_TEMPLATE, actualTableName);
List<String> result = new LinkedList<>();
Map<Integer, String> commentMap = Maps.newHashMap();
- try (Statement statement = sourceConnection.createStatement();
- ResultSet commentResult = statement.executeQuery(fetchCommentSql)) {
+ try (
+ Statement statement = sourceConnection.createStatement();
+ ResultSet commentResult = statement.executeQuery(fetchCommentSql)) {
while (commentResult.next()) {
commentMap.put(commentResult.getInt(1), commentResult.getString(2));
}
@@ -203,8 +207,9 @@ public final class PostgreSQLDataSourcePreparer extends AbstractDataSourcePrepar
}
}
final String fetchColumnSql = String.format(FETCH_TABLE_COLUMN_TEMPLATE, actualTableName);
- try (Statement statement = sourceConnection.createStatement();
- ResultSet columnsResult = statement.executeQuery(fetchColumnSql)) {
+ try (
+ Statement statement = sourceConnection.createStatement();
+ ResultSet columnsResult = statement.executeQuery(fetchColumnSql)) {
while (columnsResult.next()) {
String columnComment = commentMap.get(columnsResult.getInt(1));
if (columnComment != null) {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLJdbcDumperTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLJdbcDumperTest.java
index 931d7e00ced..7d0dc137ac2 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLJdbcDumperTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLJdbcDumperTest.java
@@ -62,8 +62,9 @@ public final class PostgreSQLJdbcDumperTest {
@SneakyThrows(SQLException.class)
private void initTableData(final DataSource dataSource) {
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
@@ -72,8 +73,9 @@ public final class PostgreSQLJdbcDumperTest {
@Test
public void assertCreatePreparedStatement() throws SQLException {
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = jdbcDumper.createPreparedStatement(connection, "SELECT * FROM t_order")) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = jdbcDumper.createPreparedStatement(connection, "SELECT * FROM t_order")) {
assertThat(preparedStatement.getFetchSize(), is(1));
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverterTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverterTest.java
index c79c6c0127a..48edec38c47 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverterTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverterTest.java
@@ -74,8 +74,9 @@ public final class WalEventConverterTest {
@SneakyThrows(SQLException.class)
private void initTableData(final DumperConfiguration dumperConfig) {
DataSource dataSource = new PipelineDataSourceManager().getDataSource(dumperConfig.getDataSourceConfig());
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2Repository.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardin [...]
index d7e82a71f08..c93074c670b 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2Repository.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2Repository.java
@@ -82,8 +82,9 @@ public final class H2Repository implements StandalonePersistRepository {
@Override
public String get(final String key) {
- try (PreparedStatement statement = connection.prepareStatement("SELECT value FROM REPOSITORY WHERE key = '" + key + "'");
- ResultSet resultSet = statement.executeQuery()) {
+ try (
+ PreparedStatement statement = connection.prepareStatement("SELECT value FROM REPOSITORY WHERE key = '" + key + "'");
+ ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) {
return Optional.ofNullable(
Strings.emptyToNull(resultSet.getString("value"))).map(each -> each.replace("\"", "'")).orElse("");
@@ -96,8 +97,9 @@ public final class H2Repository implements StandalonePersistRepository {
@Override
public List<String> getChildrenKeys(final String key) {
- try (PreparedStatement statement = connection.prepareStatement("SELECT key FROM REPOSITORY WHERE parent = '" + key + "'");
- ResultSet resultSet = statement.executeQuery()) {
+ try (
+ PreparedStatement statement = connection.prepareStatement("SELECT key FROM REPOSITORY WHERE parent = '" + key + "'");
+ ResultSet resultSet = statement.executeQuery()) {
List<String> resultChildrenList = new ArrayList<>(10);
while (resultSet.next()) {
String childrenKey = resultSet.getString("key");
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/AbstractDatabaseMetadataExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/AbstractDatabaseMetadataExecutor.java
index 4bca0df48c6..ca68efdc95c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/AbstractDatabaseMetadataExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/AbstractDatabaseMetadataExecutor.java
@@ -213,9 +213,10 @@ public abstract class AbstractDatabaseMetadataExecutor implements DatabaseAdminQ
ShardingSphereResource resource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(databaseName).getResource();
Optional<Entry<String, DataSource>> dataSourceEntry = resource.getDataSources().entrySet().stream().findFirst();
log.info("Actual SQL: {} ::: {}", dataSourceEntry.orElseThrow(DatabaseNotExistedException::new).getKey(), sql);
- try (Connection conn = dataSourceEntry.get().getValue().getConnection();
- PreparedStatement ps = conn.prepareStatement(sql);
- ResultSet resultSet = ps.executeQuery()) {
+ try (
+ Connection conn = dataSourceEntry.get().getValue().getConnection();
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ResultSet resultSet = ps.executeQuery()) {
callback.apply(resultSet);
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLFormatTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLFormatTest.java
index 9797079dd4d..5ea617920d5 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLFormatTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLFormatTest.java
@@ -96,28 +96,28 @@ public final class MySQLFormatTest {
+ "`submission_date` DATE,\n"
+ "PRIMARY KEY (`runoob_id`)\n"
+ ")ENGINE=InnoDB DEFAULT CHARSET=utf8;",
- "CREATE TABLE IF NOT EXISTS `runoob_tbl` (\n"
- + "\t`runoob_id` INT UNSIGNED AUTO_INCREMENT,\n"
- + "\t`runoob_title` VARCHAR(100) NOT NULL,\n"
- + "\t`runoob_author` VARCHAR(40) NOT NULL,\n"
- + "\t`runoob_test` NATIONAL CHAR(40),\n"
- + "\t`submission_date` DATE,\n"
- + "\tPRIMARY KEY (`runoob_id`)\n"
- + ") ENGINE = InnoDB DEFAULT CHARSET = utf8"});
+ "CREATE TABLE IF NOT EXISTS `runoob_tbl` (\n"
+ + "\t`runoob_id` INT UNSIGNED AUTO_INCREMENT,\n"
+ + "\t`runoob_title` VARCHAR(100) NOT NULL,\n"
+ + "\t`runoob_author` VARCHAR(40) NOT NULL,\n"
+ + "\t`runoob_test` NATIONAL CHAR(40),\n"
+ + "\t`submission_date` DATE,\n"
+ + "\tPRIMARY KEY (`runoob_id`)\n"
+ + ") ENGINE = InnoDB DEFAULT CHARSET = utf8"});
testUnits.add(new String[]{"insert_with_muti_value", "INSERT INTO t_order_item(order_id, user_id, status, creation_date) values (1, 1, 'insert', '2017-08-08'), (2, 2, 'insert', '2017-08-08') "
+ "ON DUPLICATE KEY UPDATE status = 'init'",
- "INSERT INTO t_order_item (order_id , user_id , status , creation_date)\n"
- + "VALUES\n"
- + "\t(1, 1, 'insert', '2017-08-08'),\n"
- + "\t(2, 2, 'insert', '2017-08-08')\n"
- + "ON DUPLICATE KEY UPDATE status = 'init'"});
+ "INSERT INTO t_order_item (order_id , user_id , status , creation_date)\n"
+ + "VALUES\n"
+ + "\t(1, 1, 'insert', '2017-08-08'),\n"
+ + "\t(2, 2, 'insert', '2017-08-08')\n"
+ + "ON DUPLICATE KEY UPDATE status = 'init'"});
testUnits.add(new String[]{"insert_with_muti_set", "INSERT INTO t_order SET order_id = 1, user_id = 1, status = convert(to_base64(aes_encrypt(1, 'key')) USING utf8) "
+ "ON DUPLICATE KEY UPDATE status = VALUES(status)",
- "INSERT INTO t_order "
- + "SET order_id = 1,\n"
- + "\tuser_id = 1,\n"
- + "\tstatus = CONVERT(to_base64(aes_encrypt(1 , 'key')) USING utf8)\n"
- + "ON DUPLICATE KEY UPDATE status = VALUES(status)"});
+ "INSERT INTO t_order "
+ + "SET order_id = 1,\n"
+ + "\tuser_id = 1,\n"
+ + "\tstatus = CONVERT(to_base64(aes_encrypt(1 , 'key')) USING utf8)\n"
+ + "ON DUPLICATE KEY UPDATE status = VALUES(status)"});
testUnits.add(new String[]{"insert_with_select", "INSERT INTO t_order (order_id, user_id, status) SELECT order_id, user_id, status FROM t_order WHERE order_id = 1", "INSERT INTO t_order "
+ "(order_id , user_id , status) \n"
+ "SELECT order_id , user_id , status \n"
@@ -131,14 +131,14 @@ public final class MySQLFormatTest {
+ "@@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, "
+ "@@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, "
+ "@@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS transaction_isolation, @@wait_timeout AS wait_timeout",
- "SELECT "
- + "@@SESSION.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, \n"
- + "\t@@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@collation_server AS collation_server, \n"
- + "\t@@collation_connection AS collation_connection, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, \n"
- + "\t@@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, \n"
- + "\t@@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, \n"
- + "\t@@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, \n"
- + "\t@@time_zone AS time_zone, @@tx_isolation AS transaction_isolation, @@wait_timeout AS wait_timeout;"});
+ "SELECT "
+ + "@@SESSION.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, \n"
+ + "\t@@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@collation_server AS collation_server, \n"
+ + "\t@@collation_connection AS collation_connection, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, \n"
+ + "\t@@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, \n"
+ + "\t@@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, \n"
+ + "\t@@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, \n"
+ + "\t@@time_zone AS time_zone, @@tx_isolation AS transaction_isolation, @@wait_timeout AS wait_timeout;"});
}
private final String caseId;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParameterizedTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParameterizedTest.java
index b52cba7df50..8bbf0191c02 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParameterizedTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParameterizedTest.java
@@ -96,14 +96,14 @@ public final class MySQLParameterizedTest {
+ "`submission_date` DATE,\n"
+ "PRIMARY KEY (`runoob_id`)\n"
+ ")ENGINE=InnoDB DEFAULT CHARSET=utf8;",
- "CREATE TABLE IF NOT EXISTS `runoob_tbl` (\n"
- + "\t`runoob_id` INT UNSIGNED AUTO_INCREMENT,\n"
- + "\t`runoob_title` VARCHAR(100) NOT NULL,\n"
- + "\t`runoob_author` VARCHAR(40) NOT NULL,\n"
- + "\t`runoob_test` NATIONAL CHAR(40),\n"
- + "\t`submission_date` DATE,\n"
- + "\tPRIMARY KEY (`runoob_id`)\n"
- + ") ENGINE = InnoDB DEFAULT CHARSET = utf8"});
+ "CREATE TABLE IF NOT EXISTS `runoob_tbl` (\n"
+ + "\t`runoob_id` INT UNSIGNED AUTO_INCREMENT,\n"
+ + "\t`runoob_title` VARCHAR(100) NOT NULL,\n"
+ + "\t`runoob_author` VARCHAR(40) NOT NULL,\n"
+ + "\t`runoob_test` NATIONAL CHAR(40),\n"
+ + "\t`submission_date` DATE,\n"
+ + "\tPRIMARY KEY (`runoob_id`)\n"
+ + ") ENGINE = InnoDB DEFAULT CHARSET = utf8"});
}
private final String caseId;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLTableVistorTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLTableVistorTest.java
index d3deed66366..2117299948b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLTableVistorTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLTableVistorTest.java
@@ -59,7 +59,7 @@ public final class MySQLTableVistorTest {
+ "`submission_date` DATE,\n"
+ "PRIMARY KEY ( `runoob_id` )\n"
+ ")ENGINE=InnoDB DEFAULT CHARSET=utf8;",
- 1, 5});
+ 1, 5});
}
private final String caseId;
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-common/src/test/java/org/apache/shardingsphere/integration/agent/test/common/env/IntegrationTestEnvironment.java b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-common/src/test/java/org/apache/shardingsphere/integration/agent/test/common/env/ [...]
index 5db4f5f4fbe..18926b4bb84 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-common/src/test/java/org/apache/shardingsphere/integration/agent/test/common/env/IntegrationTestEnvironment.java
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-common/src/test/java/org/apache/shardingsphere/integration/agent/test/common/env/IntegrationTestEnvironment.java
@@ -79,8 +79,9 @@ public final class IntegrationTestEnvironment {
String url = props.getProperty("proxy.url");
String username = props.getProperty("proxy.username", "root");
String password = props.getProperty("proxy.password", "root");
- try (Connection connection = DriverManager.getConnection(url, username, password);
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = DriverManager.getConnection(url, username, password);
+ Statement statement = connection.createStatement()) {
statement.execute("SELECT 1");
} catch (final SQLException ignore) {
return false;
diff --git a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/mix/YamlShardingWithReadwriteSplittingIntegrateTest.java b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/mix/YamlShardingWithReadwriteSplittingIntegrateTest.java
index 5f924d1bc0d..d01cfd1f11a 100644
--- a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/mix/YamlShardingWithReadwriteSplittingIntegrateTest.java
+++ b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/mix/YamlShardingWithReadwriteSplittingIntegrateTest.java
@@ -50,10 +50,10 @@ public final class YamlShardingWithReadwriteSplittingIntegrateTest extends Abstr
@Parameters(name = "{index}:{0}-{1}")
public static Collection<Object[]> init() {
return Arrays.asList(new Object[][]{
- {"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithoutProps.yaml", true},
- {"/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithoutProps.yaml", false},
- {"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithProps.yaml", true},
- {"/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithProps.yaml", false},
+ {"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithoutProps.yaml", true},
+ {"/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithoutProps.yaml", false},
+ {"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithProps.yaml", true},
+ {"/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithProps.yaml", false},
});
}
@@ -71,8 +71,9 @@ public final class YamlShardingWithReadwriteSplittingIntegrateTest extends Abstr
}
dataSource = YamlShardingSphereDataSourceFactory.createDataSource(result, yamlFile);
}
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute(String.format("INSERT INTO t_order(user_id,status) values(%d, %s)", 10, "'insert'"));
statement.executeQuery("SELECT * FROM t_order");
statement.executeQuery("SELECT * FROM t_order_item");
diff --git a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/readwrite/YamlReadwriteSplittingIntegrateTest.java b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/readwrite/YamlReadwriteSplittingIntegrateTest.java
index 43ad5e164a7..02f05a36714 100644
--- a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/readwrite/YamlReadwriteSplittingIntegrateTest.java
+++ b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/readwrite/YamlReadwriteSplittingIntegrateTest.java
@@ -47,10 +47,10 @@ public final class YamlReadwriteSplittingIntegrateTest extends AbstractYamlDataS
@Parameters(name = "{index}:{0}-{1}")
public static Collection<Object[]> init() {
return Arrays.asList(new Object[][]{
- {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithoutProps.yaml", true},
- {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithoutProps.yaml", true},
- {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithProps.yaml", true},
- {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithProps.yaml", true},
+ {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithoutProps.yaml", true},
+ {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithoutProps.yaml", true},
+ {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithProps.yaml", true},
+ {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithProps.yaml", true},
});
}
@@ -64,8 +64,9 @@ public final class YamlReadwriteSplittingIntegrateTest extends AbstractYamlDataS
dataSource = YamlShardingSphereDataSourceFactory.createDataSource(
Maps.asMap(Sets.newHashSet("db_write", "read_ds_0", "read_ds_1"), AbstractYamlDataSourceTest::createDataSource), yamlFile);
}
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.executeQuery("SELECT * FROM t_order");
statement.executeQuery("SELECT * FROM t_order_item");
statement.executeQuery("SELECT * FROM t_config");
@@ -83,8 +84,9 @@ public final class YamlReadwriteSplittingIntegrateTest extends AbstractYamlDataS
dataSource = YamlShardingSphereDataSourceFactory.createDataSource(
Maps.asMap(Sets.newHashSet("db_write", "read_ds_0", "read_ds_1"), AbstractYamlDataSourceTest::createDataSource), yamlFile);
}
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.executeQuery("SELECT * FROM t_order");
statement.executeQuery("SELECT * FROM t_order_item");
statement.executeQuery("SELECT * FROM t_config");
diff --git a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/sharding/YamlShardingIntegrateTest.java b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/sharding/YamlShardingIntegrateTest.java
index 4d8de957eea..5bd525dce62 100644
--- a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/sharding/YamlShardingIntegrateTest.java
+++ b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/sharding/YamlShardingIntegrateTest.java
@@ -47,10 +47,10 @@ public class YamlShardingIntegrateTest extends AbstractYamlDataSourceTest {
@Parameters(name = "{index}:{0}-{1}")
public static Collection<Object[]> init() {
return Arrays.asList(new Object[][]{
- {"/yaml/integrate/sharding/configWithDataSourceWithoutProps.yaml", true},
- {"/yaml/integrate/sharding/configWithoutDataSourceWithoutProps.yaml", false},
- {"/yaml/integrate/sharding/configWithDataSourceWithProps.yaml", true},
- {"/yaml/integrate/sharding/configWithoutDataSourceWithProps.yaml", false},
+ {"/yaml/integrate/sharding/configWithDataSourceWithoutProps.yaml", true},
+ {"/yaml/integrate/sharding/configWithoutDataSourceWithoutProps.yaml", false},
+ {"/yaml/integrate/sharding/configWithDataSourceWithProps.yaml", true},
+ {"/yaml/integrate/sharding/configWithoutDataSourceWithProps.yaml", false},
});
}
@@ -63,8 +63,9 @@ public class YamlShardingIntegrateTest extends AbstractYamlDataSourceTest {
} else {
dataSource = YamlShardingSphereDataSourceFactory.createDataSource(Maps.asMap(Sets.newHashSet("db0", "db1"), AbstractYamlDataSourceTest::createDataSource), yamlFile);
}
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute(String.format("INSERT INTO t_order(user_id,status) values(%d, %s)", 10, "'insert'"));
statement.executeQuery("SELECT * FROM t_order");
statement.executeQuery("SELECT * FROM t_order_item");
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/fixture/DataImporter.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/fixture/DataImporter.java
index 07013bbc20f..55248ddb573 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/fixture/DataImporter.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/fixture/DataImporter.java
@@ -55,8 +55,9 @@ public final class DataImporter {
@SneakyThrows(SQLException.class)
private void createTable(final DataSource dataSource, final String tableName, final String columnName, final String columnType) {
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(String.format(CREATE_SQL, tableName, columnName, columnType))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(String.format(CREATE_SQL, tableName, columnName, columnType))) {
preparedStatement.execute();
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BatchITCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BatchITCase.java
index 0dfa9192fe0..52b38d37ae7 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BatchITCase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BatchITCase.java
@@ -84,8 +84,9 @@ public abstract class BatchITCase extends BaseITCase {
for (String each : new InlineExpressionParser(expectedDataSetMetaData.getDataNodes()).splitAndEvaluate()) {
DataNode dataNode = new DataNode(each);
DataSource dataSource = getActualDataSourceMap().get(dataNode.getDataSourceName());
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(String.format("SELECT * FROM %s ORDER BY 1", dataNode.getTableName()))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(String.format("SELECT * FROM %s ORDER BY 1", dataNode.getTableName()))) {
assertDataSet(preparedStatement, expected.findRows(dataNode), expectedDataSetMetaData);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dal/GeneralDALIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dal/GeneralDALIT.java
index 97a7c370648..cdf4ee441ca 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dal/GeneralDALIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dal/GeneralDALIT.java
@@ -47,8 +47,9 @@ public final class GeneralDALIT extends BaseDALIT {
@Test
public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
- try (Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSQL())) {
+ try (
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getSQL())) {
assertResultSet(resultSet);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BaseDMLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BaseDMLIT.java
index 866d25d30ed..02c74d2f6e3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BaseDMLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BaseDMLIT.java
@@ -73,8 +73,9 @@ public abstract class BaseDMLIT extends SingleITCase {
for (String each : new InlineExpressionParser(expectedDataSetMetaData.getDataNodes()).splitAndEvaluate()) {
DataNode dataNode = new DataNode(each);
DataSource dataSource = getActualDataSourceMap().get(dataNode.getDataSourceName());
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(generateFetchActualDataSQL(dataNode))) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(generateFetchActualDataSQL(dataNode))) {
assertDataSet(preparedStatement, expectedDataSetMetaData, getDataSet().findRows(dataNode));
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BatchDMLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BatchDMLIT.java
index 22f348a2fb8..c1376c20744 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BatchDMLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BatchDMLIT.java
@@ -89,8 +89,9 @@ public final class BatchDMLIT extends BatchITCase {
return;
default:
}
- try (Connection connection = getTargetDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getItCase().getSql())) {
+ try (
+ Connection connection = getTargetDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getItCase().getSql())) {
for (IntegrationTestCaseAssertion each : getItCase().getAssertions()) {
addBatch(preparedStatement, each);
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/AdditionalDQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/AdditionalDQLIT.java
index 1f5acf9c7af..e236f07cfae 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/AdditionalDQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/AdditionalDQLIT.java
@@ -53,8 +53,9 @@ public final class AdditionalDQLIT extends BaseDQLIT {
@Test
public void assertExecuteQueryWithResultSetTypeAndResultSetConcurrency() throws SQLException, ParseException {
- try (Connection actualConnection = getTargetDataSource().getConnection();
- Connection expectedConnection = getExpectedDataSource().getConnection()) {
+ try (
+ Connection actualConnection = getTargetDataSource().getConnection();
+ Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteQueryForStatementWithResultSetTypeAndResultSetConcurrency(actualConnection, expectedConnection);
} else {
@@ -65,10 +66,11 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void assertExecuteQueryForStatementWithResultSetTypeAndResultSetConcurrency(
final Connection actualConnection, final Connection expectedConnection) throws SQLException, ParseException {
- try (Statement actualStatement = actualConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- ResultSet actualResultSet = actualStatement.executeQuery(String.format(getSQL(), getAssertion().getSQLValues().toArray()));
- Statement expectedStatement = expectedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- ResultSet expectedResultSet = expectedStatement.executeQuery(String.format(getSQL(), getAssertion().getSQLValues().toArray()))) {
+ try (
+ Statement actualStatement = actualConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ ResultSet actualResultSet = actualStatement.executeQuery(String.format(getSQL(), getAssertion().getSQLValues().toArray()));
+ Statement expectedStatement = expectedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ ResultSet expectedResultSet = expectedStatement.executeQuery(String.format(getSQL(), getAssertion().getSQLValues().toArray()))) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
@@ -76,14 +78,16 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void assertExecuteQueryForPreparedStatementWithResultSetTypeAndResultSetConcurrency(
final Connection actualConnection,
final Connection expectedConnection) throws SQLException, ParseException {
- try (PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
+ try (
+ PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
for (SQLValue each : getAssertion().getSQLValues()) {
actualPreparedStatement.setObject(each.getIndex(), each.getValue());
expectedPreparedStatement.setObject(each.getIndex(), each.getValue());
}
- try (ResultSet actualResultSet = actualPreparedStatement.executeQuery();
- ResultSet expectedResultSet = expectedPreparedStatement.executeQuery()) {
+ try (
+ ResultSet actualResultSet = actualPreparedStatement.executeQuery();
+ ResultSet expectedResultSet = expectedPreparedStatement.executeQuery()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
@@ -91,8 +95,9 @@ public final class AdditionalDQLIT extends BaseDQLIT {
@Test
public void assertExecuteQueryWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability() throws SQLException, ParseException {
- try (Connection actualConnection = getTargetDataSource().getConnection();
- Connection expectedConnection = getExpectedDataSource().getConnection()) {
+ try (
+ Connection actualConnection = getTargetDataSource().getConnection();
+ Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteQueryForStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(actualConnection, expectedConnection);
} else {
@@ -105,10 +110,11 @@ public final class AdditionalDQLIT extends BaseDQLIT {
final Connection actualConnection,
final Connection expectedConnection) throws SQLException, ParseException {
String sql = String.format(getSQL(), getAssertion().getSQLValues().toArray());
- try (Statement actualStatement = actualConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- ResultSet actualResultSet = actualStatement.executeQuery(sql);
- Statement expectedStatement = expectedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- ResultSet expectedResultSet = expectedStatement.executeQuery(sql)) {
+ try (
+ Statement actualStatement = actualConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ ResultSet actualResultSet = actualStatement.executeQuery(sql);
+ Statement expectedStatement = expectedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ ResultSet expectedResultSet = expectedStatement.executeQuery(sql)) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
@@ -116,15 +122,17 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void assertExecuteQueryForPreparedStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(
final Connection actualConnection,
final Connection expectedConnection) throws SQLException, ParseException {
- try (PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(
- getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ try (
+ PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(
+ getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
for (SQLValue each : getAssertion().getSQLValues()) {
actualPreparedStatement.setObject(each.getIndex(), each.getValue());
expectedPreparedStatement.setObject(each.getIndex(), each.getValue());
}
- try (ResultSet actualResultSet = actualPreparedStatement.executeQuery();
- ResultSet expectedResultSet = expectedPreparedStatement.executeQuery()) {
+ try (
+ ResultSet actualResultSet = actualPreparedStatement.executeQuery();
+ ResultSet expectedResultSet = expectedPreparedStatement.executeQuery()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
@@ -132,8 +140,9 @@ public final class AdditionalDQLIT extends BaseDQLIT {
@Test
public void assertExecuteWithResultSetTypeAndResultSetConcurrency() throws SQLException, ParseException {
- try (Connection actualConnection = getTargetDataSource().getConnection();
- Connection expectedConnection = getExpectedDataSource().getConnection()) {
+ try (
+ Connection actualConnection = getTargetDataSource().getConnection();
+ Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteForStatementWithResultSetTypeAndResultSetConcurrency(actualConnection, expectedConnection);
} else {
@@ -143,12 +152,14 @@ public final class AdditionalDQLIT extends BaseDQLIT {
}
private void assertExecuteForStatementWithResultSetTypeAndResultSetConcurrency(final Connection actualConnection, final Connection expectedConnection) throws SQLException, ParseException {
- try (Statement actualStatement = actualConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- Statement expectedStatement = expectedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
+ try (
+ Statement actualStatement = actualConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ Statement expectedStatement = expectedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
String sql = String.format(getSQL(), getAssertion().getSQLValues().toArray());
assertTrue("Not a query statement.", actualStatement.execute(sql) && expectedStatement.execute(sql));
- try (ResultSet actualResultSet = actualStatement.getResultSet();
- ResultSet expectedResultSet = expectedStatement.getResultSet()) {
+ try (
+ ResultSet actualResultSet = actualStatement.getResultSet();
+ ResultSet expectedResultSet = expectedStatement.getResultSet()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
@@ -156,15 +167,17 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void assertExecuteForPreparedStatementWithResultSetTypeAndResultSetConcurrency(
final Connection actualConnection, final Connection expectedConnection) throws SQLException, ParseException {
- try (PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
+ try (
+ PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
for (SQLValue each : getAssertion().getSQLValues()) {
actualPreparedStatement.setObject(each.getIndex(), each.getValue());
expectedPreparedStatement.setObject(each.getIndex(), each.getValue());
}
assertTrue("Not a query statement.", actualPreparedStatement.execute() && expectedPreparedStatement.execute());
- try (ResultSet actualResultSet = actualPreparedStatement.getResultSet();
- ResultSet expectedResultSet = expectedPreparedStatement.getResultSet()) {
+ try (
+ ResultSet actualResultSet = actualPreparedStatement.getResultSet();
+ ResultSet expectedResultSet = expectedPreparedStatement.getResultSet()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
@@ -172,8 +185,9 @@ public final class AdditionalDQLIT extends BaseDQLIT {
@Test
public void assertExecuteWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability() throws SQLException, ParseException {
- try (Connection actualConnection = getTargetDataSource().getConnection();
- Connection expectedConnection = getExpectedDataSource().getConnection()) {
+ try (
+ Connection actualConnection = getTargetDataSource().getConnection();
+ Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteForStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(actualConnection, expectedConnection);
} else {
@@ -185,12 +199,14 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void assertExecuteForStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(
final Connection actualConnection,
final Connection expectedConnection) throws SQLException, ParseException {
- try (Statement actualStatement = actualConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- Statement expectedStatement = expectedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ try (
+ Statement actualStatement = actualConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ Statement expectedStatement = expectedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
String sql = String.format(getSQL(), getAssertion().getSQLValues().toArray());
assertTrue("Not a query statement.", actualStatement.execute(sql) && expectedStatement.execute(sql));
- try (ResultSet actualResultSet = actualStatement.getResultSet();
- ResultSet expectedResultSet = expectedStatement.getResultSet()) {
+ try (
+ ResultSet actualResultSet = actualStatement.getResultSet();
+ ResultSet expectedResultSet = expectedStatement.getResultSet()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
@@ -199,16 +215,18 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void assertExecuteForPreparedStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(
final Connection actualConnection,
final Connection expectedConnection) throws SQLException, ParseException {
- try (PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(
- getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ try (
+ PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(
+ getSQL(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
for (SQLValue each : getAssertion().getSQLValues()) {
actualPreparedStatement.setObject(each.getIndex(), each.getValue());
expectedPreparedStatement.setObject(each.getIndex(), each.getValue());
}
assertTrue("Not a query statement.", actualPreparedStatement.execute() && expectedPreparedStatement.execute());
- try (ResultSet actualResultSet = actualPreparedStatement.getResultSet();
- ResultSet expectedResultSet = expectedPreparedStatement.getResultSet()) {
+ try (
+ ResultSet actualResultSet = actualPreparedStatement.getResultSet();
+ ResultSet expectedResultSet = expectedPreparedStatement.getResultSet()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/GeneralDQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/GeneralDQLIT.java
index 0ba32620d4f..062151f4f5f 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/GeneralDQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/GeneralDQLIT.java
@@ -51,8 +51,9 @@ public final class GeneralDQLIT extends BaseDQLIT {
@Test
public void assertExecuteQuery() throws SQLException, ParseException {
- try (Connection actualConnection = getTargetDataSource().getConnection();
- Connection expectedConnection = getExpectedDataSource().getConnection()) {
+ try (
+ Connection actualConnection = getTargetDataSource().getConnection();
+ Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteQueryForStatement(actualConnection, expectedConnection);
} else {
@@ -62,23 +63,26 @@ public final class GeneralDQLIT extends BaseDQLIT {
}
private void assertExecuteQueryForStatement(final Connection actualConnection, final Connection expectedConnection) throws SQLException, ParseException {
- try (Statement actualStatement = actualConnection.createStatement();
- ResultSet actualResultSet = actualStatement.executeQuery(getSQL());
- Statement expectedStatement = expectedConnection.createStatement();
- ResultSet expectedResultSet = expectedStatement.executeQuery(getSQL())) {
+ try (
+ Statement actualStatement = actualConnection.createStatement();
+ ResultSet actualResultSet = actualStatement.executeQuery(getSQL());
+ Statement expectedStatement = expectedConnection.createStatement();
+ ResultSet expectedResultSet = expectedStatement.executeQuery(getSQL())) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
private void assertExecuteQueryForPreparedStatement(final Connection actualConnection, final Connection expectedConnection) throws SQLException, ParseException {
- try (PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL());
- PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(getSQL())) {
+ try (
+ PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL());
+ PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(getSQL())) {
for (SQLValue each : getAssertion().getSQLValues()) {
actualPreparedStatement.setObject(each.getIndex(), each.getValue());
expectedPreparedStatement.setObject(each.getIndex(), each.getValue());
}
- try (ResultSet actualResultSet = actualPreparedStatement.executeQuery();
- ResultSet expectedResultSet = expectedPreparedStatement.executeQuery()) {
+ try (
+ ResultSet actualResultSet = actualPreparedStatement.executeQuery();
+ ResultSet expectedResultSet = expectedPreparedStatement.executeQuery()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
@@ -86,8 +90,9 @@ public final class GeneralDQLIT extends BaseDQLIT {
@Test
public void assertExecute() throws SQLException, ParseException {
- try (Connection actualConnection = getTargetDataSource().getConnection();
- Connection expectedConnection = getExpectedDataSource().getConnection()) {
+ try (
+ Connection actualConnection = getTargetDataSource().getConnection();
+ Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteForStatement(actualConnection, expectedConnection);
} else {
@@ -97,26 +102,30 @@ public final class GeneralDQLIT extends BaseDQLIT {
}
private void assertExecuteForStatement(final Connection actualConnection, final Connection expectedConnection) throws SQLException, ParseException {
- try (Statement actualStatement = actualConnection.createStatement();
- Statement expectedStatement = expectedConnection.createStatement()) {
+ try (
+ Statement actualStatement = actualConnection.createStatement();
+ Statement expectedStatement = expectedConnection.createStatement()) {
assertTrue("Not a query statement.", actualStatement.execute(getSQL()) && expectedStatement.execute(getSQL()));
- try (ResultSet actualResultSet = actualStatement.getResultSet();
- ResultSet expectedResultSet = expectedStatement.getResultSet()) {
+ try (
+ ResultSet actualResultSet = actualStatement.getResultSet();
+ ResultSet expectedResultSet = expectedStatement.getResultSet()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
}
private void assertExecuteForPreparedStatement(final Connection actualConnection, final Connection expectedConnection) throws SQLException, ParseException {
- try (PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL());
- PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(getSQL())) {
+ try (
+ PreparedStatement actualPreparedStatement = actualConnection.prepareStatement(getSQL());
+ PreparedStatement expectedPreparedStatement = expectedConnection.prepareStatement(getSQL())) {
for (SQLValue each : getAssertion().getSQLValues()) {
actualPreparedStatement.setObject(each.getIndex(), each.getValue());
expectedPreparedStatement.setObject(each.getIndex(), each.getValue());
}
assertTrue("Not a query statement.", actualPreparedStatement.execute() && expectedPreparedStatement.execute());
- try (ResultSet actualResultSet = actualPreparedStatement.getResultSet();
- ResultSet expectedResultSet = expectedPreparedStatement.getResultSet()) {
+ try (
+ ResultSet actualResultSet = actualPreparedStatement.getResultSet();
+ ResultSet expectedResultSet = expectedPreparedStatement.getResultSet()) {
assertResultSet(actualResultSet, expectedResultSet);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ral/GeneralRALIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ral/GeneralRALIT.java
index b07a61cabc8..f0ddad5264b 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ral/GeneralRALIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ral/GeneralRALIT.java
@@ -47,8 +47,9 @@ public final class GeneralRALIT extends BaseRALIT {
@Test
public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
- try (Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSQL())) {
+ try (
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getSQL())) {
assertResultSet(resultSet);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rdl/GeneralRDLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rdl/GeneralRDLIT.java
index 992b727b537..b4666049e8d 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rdl/GeneralRDLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rdl/GeneralRDLIT.java
@@ -47,8 +47,9 @@ public final class GeneralRDLIT extends BaseRDLIT {
@Test
public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
- try (Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSQL())) {
+ try (
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getSQL())) {
assertResultSet(resultSet);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rql/GeneralRQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rql/GeneralRQLIT.java
index f8f149e5781..7d51dd0b0f1 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rql/GeneralRQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rql/GeneralRQLIT.java
@@ -47,8 +47,9 @@ public final class GeneralRQLIT extends BaseRQLIT {
@Test
public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
- try (Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSQL())) {
+ try (
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(getSQL())) {
assertResultSet(resultSet);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/scenario/dataset/DataSetEnvironmentManager.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/scenario/dataset/DataSetEnvironmentManager.java
index 014e6b49765..4aa1a4aabf5 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/scenario/dataset/DataSetEnvironmentManager.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/scenario/dataset/DataSetEnvironmentManager.java
@@ -182,8 +182,9 @@ public final class DataSetEnvironmentManager {
@Override
public Void call() throws SQLException {
- try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(insertSQL)) {
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(insertSQL)) {
for (SQLValueGroup each : sqlValueGroups) {
setParameters(preparedStatement, each);
preparedStatement.addBatch();
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/container/atomic/storage/impl/H2Container.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/container/atomic/storage/impl/H2Container.java
index 2f7b9b1c849..ff1813cc80a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/container/atomic/storage/impl/H2Container.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/container/atomic/storage/impl/H2Container.java
@@ -68,8 +68,9 @@ public final class H2Container extends EmbeddedStorageContainer {
}
private void executeInitSQL(final DataSource dataSource, final String initSQLFile) throws SQLException, IOException {
- try (Connection connection = dataSource.getConnection();
- FileReader reader = new FileReader(initSQLFile)) {
+ try (
+ Connection connection = dataSource.getConnection();
+ FileReader reader = new FileReader(initSQLFile)) {
RunScript.execute(connection, reader);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/database/impl/PostgreSQLDatabaseAssertionMetaData.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/database/impl/PostgreSQLDatabaseAssertionMetaData.java
index 71311f59396..8bf445b754d 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/database/impl/PostgreSQLDatabaseAssertionMetaData.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/database/impl/PostgreSQLDatabaseAssertionMetaData.java
@@ -34,9 +34,10 @@ public final class PostgreSQLDatabaseAssertionMetaData implements DatabaseAssert
public String getPrimaryKeyColumnName(final DataSource dataSource, final String tableName) throws SQLException {
String sql = String.format("SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS data_type "
+ "FROM pg_index i JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey) WHERE i.indrelid = '%s'::regclass AND i.indisprimary", tableName);
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(sql)) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(sql)) {
if (resultSet.next()) {
return resultSet.getString("attname");
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/watcher/ITWatcher.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/watcher/ITWatcher.java
index f858223d362..f6fa257bdd2 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/watcher/ITWatcher.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/watcher/ITWatcher.java
@@ -40,8 +40,9 @@ public final class ITWatcher extends TestWatcher {
if (null == cause) {
return "";
}
- try (ByteArrayOutputStream out = new ByteArrayOutputStream();
- PrintStream printStream = new PrintStream(out)) {
+ try (
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ PrintStream printStream = new PrintStream(out)) {
cause.printStackTrace(printStream);
printStream.flush();
return out.toString();
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/api/impl/RuleAlteredJobAPIImplTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/api/impl/RuleAlteredJobAPIImplTest.java
index 54a339c5f41..354a0553368 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/api/impl/RuleAlteredJobAPIImplTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/api/impl/RuleAlteredJobAPIImplTest.java
@@ -243,8 +243,9 @@ public final class RuleAlteredJobAPIImplTest {
}
private void initTableData(final DataSource pipelineDataSource) throws SQLException {
- try (Connection connection = pipelineDataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = pipelineDataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyCheckerTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyCheckerTest.java
index 9bf74d1caba..9ba77b75ddc 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyCheckerTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyCheckerTest.java
@@ -60,8 +60,9 @@ public final class DataConsistencyCheckerTest {
}
private void initTableData(final PipelineDataSourceConfiguration dataSourceConfig) throws SQLException {
- try (Connection connection = new PipelineDataSourceManager().getDataSource(dataSourceConfig).getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = new PipelineDataSourceManager().getDataSource(dataSourceConfig).getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/InventoryTaskTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/InventoryTaskTest.java
index 491bff39c10..c40de0ea22b 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/InventoryTaskTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/InventoryTaskTest.java
@@ -68,9 +68,10 @@ public final class InventoryTaskTest {
inventoryDumperConfig.setPosition(position);
PipelineDataSourceWrapper dataSource = DATA_SOURCE_MANAGER.getDataSource(inventoryDumperConfig.getDataSourceConfig());
PipelineTableMetaDataLoader metaDataLoader = new PipelineTableMetaDataLoader(dataSource);
- try (InventoryTask inventoryTask = new InventoryTask(inventoryDumperConfig, taskConfig.getImporterConfig(),
- PipelineContextUtil.getPipelineChannelFactory(),
- DATA_SOURCE_MANAGER, dataSource, metaDataLoader, PipelineContextUtil.getExecuteEngine())) {
+ try (
+ InventoryTask inventoryTask = new InventoryTask(inventoryDumperConfig, taskConfig.getImporterConfig(),
+ PipelineContextUtil.getPipelineChannelFactory(),
+ DATA_SOURCE_MANAGER, dataSource, metaDataLoader, PipelineContextUtil.getExecuteEngine())) {
inventoryTask.start();
}
}
@@ -87,19 +88,21 @@ public final class InventoryTaskTest {
inventoryDumperConfig.setPosition(position);
PipelineDataSourceWrapper dataSource = DATA_SOURCE_MANAGER.getDataSource(inventoryDumperConfig.getDataSourceConfig());
PipelineTableMetaDataLoader metaDataLoader = new PipelineTableMetaDataLoader(dataSource);
- try (InventoryTask inventoryTask = new InventoryTask(inventoryDumperConfig, taskConfig.getImporterConfig(),
- PipelineContextUtil.getPipelineChannelFactory(),
- new PipelineDataSourceManager(), dataSource, metaDataLoader, PipelineContextUtil.getExecuteEngine())) {
+ try (
+ InventoryTask inventoryTask = new InventoryTask(inventoryDumperConfig, taskConfig.getImporterConfig(),
+ PipelineContextUtil.getPipelineChannelFactory(),
+ new PipelineDataSourceManager(), dataSource, metaDataLoader, PipelineContextUtil.getExecuteEngine())) {
inventoryTask.start();
assertFalse(inventoryTask.getProgress().getPosition() instanceof FinishedPosition);
}
}
private void initTableData(final DumperConfiguration dumperConfig) throws SQLException {
- try (PipelineDataSourceManager dataSourceManager = new PipelineDataSourceManager();
- PipelineDataSourceWrapper dataSource = dataSourceManager.getDataSource(dumperConfig.getDataSourceConfig());
- Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ PipelineDataSourceManager dataSourceManager = new PipelineDataSourceManager();
+ PipelineDataSourceWrapper dataSource = dataSourceManager.getDataSource(dumperConfig.getDataSourceConfig());
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobTest.java
index df17842de36..5e2b7845a8f 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobTest.java
@@ -62,9 +62,10 @@ public final class RuleAlteredJobTest {
@SneakyThrows(SQLException.class)
private void initTableData(final JobConfiguration jobConfig) {
YamlPipelineDataSourceConfiguration source = jobConfig.getPipelineConfig().getSource();
- try (PipelineDataSourceWrapper dataSource = PipelineDataSourceFactory.newInstance(PipelineDataSourceConfigurationFactory.newInstance(source.getType(), source.getParameter()));
- Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ PipelineDataSourceWrapper dataSource = PipelineDataSourceFactory.newInstance(PipelineDataSourceConfigurationFactory.newInstance(source.getType(), source.getParameter()));
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/prepare/InventoryTaskSplitterTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/prepare/InventoryTaskSplitterTest.java
index 7ce44e7b925..cd63cb74f82 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/prepare/InventoryTaskSplitterTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/prepare/InventoryTaskSplitterTest.java
@@ -108,8 +108,9 @@ public final class InventoryTaskSplitterTest {
private void initEmptyTablePrimaryEnvironment(final DumperConfiguration dumperConfig) throws SQLException {
DataSource dataSource = dataSourceManager.getDataSource(dumperConfig.getDataSourceConfig());
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
}
@@ -117,8 +118,9 @@ public final class InventoryTaskSplitterTest {
private void initIntPrimaryEnvironment(final DumperConfiguration dumperConfig) throws SQLException {
DataSource dataSource = dataSourceManager.getDataSource(dumperConfig.getDataSourceConfig());
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id VARCHAR(12))");
for (int i = 1; i <= 100; i++) {
@@ -129,8 +131,9 @@ public final class InventoryTaskSplitterTest {
private void initCharPrimaryEnvironment(final DumperConfiguration dumperConfig) throws SQLException {
DataSource dataSource = dataSourceManager.getDataSource(dumperConfig.getDataSourceConfig());
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id CHAR(3) PRIMARY KEY, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES ('1', 'xxx'), ('999', 'yyy')");
@@ -139,8 +142,9 @@ public final class InventoryTaskSplitterTest {
private void initUnionPrimaryEnvironment(final DumperConfiguration dumperConfig) throws SQLException {
DataSource dataSource = dataSourceManager.getDataSource(dumperConfig.getDataSourceConfig());
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT, user_id VARCHAR(12), PRIMARY KEY (order_id, user_id))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
@@ -149,8 +153,9 @@ public final class InventoryTaskSplitterTest {
private void initNoPrimaryEnvironment(final DumperConfiguration dumperConfig) throws SQLException {
DataSource dataSource = dataSourceManager.getDataSource(dumperConfig.getDataSourceConfig());
- try (Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement()) {
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT, user_id VARCHAR(12))");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 'xxx'), (999, 'yyy')");
diff --git a/src/resources/checkstyle_ci.xml b/src/resources/checkstyle_ci.xml
index 4be80579a50..1b02563e5b0 100644
--- a/src/resources/checkstyle_ci.xml
+++ b/src/resources/checkstyle_ci.xml
@@ -205,7 +205,10 @@
<module name="AvoidEscapedUnicodeCharacters"/>
<module name="DescendantToken"/>
<module name="FinalParameters"/>
- <module name="Indentation"/>
+ <module name="Indentation">
+ <property name="arrayInitIndent" value="2"/>
+ <property name="lineWrappingIndentation" value="8"/>
+ </module>
<module name="OuterTypeFilename"/>
<module name="TodoComment"/>
<module name="TrailingComment"/>
diff --git a/src/resources/shardingsphere_eclipse_formatter.xml b/src/resources/shardingsphere_eclipse_formatter.xml
index bb163eab7f8..cb38761c973 100644
--- a/src/resources/shardingsphere_eclipse_formatter.xml
+++ b/src/resources/shardingsphere_eclipse_formatter.xml
@@ -39,8 +39,8 @@
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
- <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="1"/>
- <setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="110"/>
+ <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="160"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="10"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="106"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="106"/>