Skip to content

Commit 0678440

Browse files
committed
Removed redundant semicolons, corrected format, etc.
1 parent 73b4569 commit 0678440

File tree

4 files changed

+22
-38
lines changed

4 files changed

+22
-38
lines changed

src/main/java/org/apache/ibatis/io/DefaultVFS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ protected boolean isJar(URL url) {
329329
* @return true, if is jar
330330
*/
331331
protected boolean isJar(URL url, byte[] buffer) {
332-
try(InputStream is = url.openStream()) {
332+
try (InputStream is = url.openStream()) {
333333
is.read(buffer, 0, JAR_MAGIC.length);
334334
if (Arrays.equals(buffer, JAR_MAGIC)) {
335335
if (log.isDebugEnabled()) {

src/main/java/org/apache/ibatis/io/ResolverUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
* by calling {@link #setClassLoader(ClassLoader)} prior to invoking any of the {@code find()}
3838
* methods.</p>
3939
*
40-
* <p>General searches are initiated by calling the
41-
* {@link #find(org.apache.ibatis.io.ResolverUtil.Test, String)} () method and supplying
40+
* <p>General searches are initiated by calling the {@link #find(Test, String)} and supplying
4241
* a package name and a Test instance. This will cause the named package <b>and all sub-packages</b>
4342
* to be scanned for classes that meet the test. There are also utility methods for the common
4443
* use cases of scanning multiple packages for extensions of particular classes, or classes

src/main/java/org/apache/ibatis/jdbc/ScriptRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private boolean commandReadyToExecute(String trimmedLine) {
238238
}
239239

240240
private void executeStatement(String command) throws SQLException {
241-
try(Statement statement = connection.createStatement()) {
241+
try (Statement statement = connection.createStatement()) {
242242
statement.setEscapeProcessing(escapeProcessing);
243243
String sql = command;
244244
if (removeCRs) {

src/main/java/org/apache/ibatis/jdbc/SqlRunner.java

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/**
2-
* Copyright 2009-2020 the original author or authors.
3-
* <p>
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
* <p>
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
* <p>
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
2+
* Copyright 2009-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1515
*/
1616
package org.apache.ibatis.jdbc;
1717

@@ -57,9 +57,7 @@ public void setUseGeneratedKeySupport(boolean useGeneratedKeySupport) {
5757
*
5858
* @param sql The SQL
5959
* @param args The arguments to be set on the statement.
60-
*
6160
* @return The row expected.
62-
*
6361
* @throws SQLException If less or more than one row is returned
6462
*/
6563
public Map<String, Object> selectOne(String sql, Object... args) throws SQLException {
@@ -75,15 +73,13 @@ public Map<String, Object> selectOne(String sql, Object... args) throws SQLExcep
7573
*
7674
* @param sql The SQL
7775
* @param args The arguments to be set on the statement.
78-
*
7976
* @return The list of rows expected.
80-
*
8177
* @throws SQLException If statement preparation or execution fails
8278
*/
8379
public List<Map<String, Object>> selectAll(String sql, Object... args) throws SQLException {
84-
try (PreparedStatement ps = connection.prepareStatement(sql);) {
80+
try (PreparedStatement ps = connection.prepareStatement(sql)) {
8581
setParameters(ps, args);
86-
try (ResultSet rs = ps.executeQuery();) {
82+
try (ResultSet rs = ps.executeQuery()) {
8783
return getResults(rs);
8884
}
8985
}
@@ -94,9 +90,7 @@ public List<Map<String, Object>> selectAll(String sql, Object... args) throws SQ
9490
*
9591
* @param sql The SQL
9692
* @param args The arguments to be set on the statement.
97-
*
9893
* @return The number of rows impacted or BATCHED_RESULTS if the statements are being batched.
99-
*
10094
* @throws SQLException If statement preparation or execution fails
10195
*/
10296
public int insert(String sql, Object... args) throws SQLException {
@@ -111,7 +105,7 @@ public int insert(String sql, Object... args) throws SQLException {
111105
setParameters(ps, args);
112106
ps.executeUpdate();
113107
if (useGeneratedKeySupport) {
114-
try (ResultSet generatedKeys = ps.getGeneratedKeys();) {
108+
try (ResultSet generatedKeys = ps.getGeneratedKeys()) {
115109
List<Map<String, Object>> keys = getResults(generatedKeys);
116110
if (keys.size() == 1) {
117111
Map<String, Object> key = keys.get(0);
@@ -144,13 +138,11 @@ public int insert(String sql, Object... args) throws SQLException {
144138
*
145139
* @param sql The SQL
146140
* @param args The arguments to be set on the statement.
147-
*
148141
* @return The number of rows impacted or BATCHED_RESULTS if the statements are being batched.
149-
*
150142
* @throws SQLException If statement preparation or execution fails
151143
*/
152144
public int update(String sql, Object... args) throws SQLException {
153-
try (PreparedStatement ps = connection.prepareStatement(sql);) {
145+
try (PreparedStatement ps = connection.prepareStatement(sql)) {
154146
setParameters(ps, args);
155147
return ps.executeUpdate();
156148
}
@@ -161,9 +153,7 @@ public int update(String sql, Object... args) throws SQLException {
161153
*
162154
* @param sql The SQL
163155
* @param args The arguments to be set on the statement.
164-
*
165156
* @return The number of rows impacted or BATCHED_RESULTS if the statements are being batched.
166-
*
167157
* @throws SQLException If statement preparation or execution fails
168158
*/
169159
public int delete(String sql, Object... args) throws SQLException {
@@ -175,11 +165,10 @@ public int delete(String sql, Object... args) throws SQLException {
175165
* Good for DDL
176166
*
177167
* @param sql The SQL
178-
*
179168
* @throws SQLException If statement preparation or execution fails
180169
*/
181170
public void run(String sql) throws SQLException {
182-
try (Statement stmt = connection.createStatement();) {
171+
try (Statement stmt = connection.createStatement()) {
183172
stmt.execute(sql);
184173
}
185174
}
@@ -199,8 +188,7 @@ public void closeConnection() {
199188
private void setParameters(PreparedStatement ps, Object... args) throws SQLException {
200189
for (int i = 0, n = args.length; i < n; i++) {
201190
if (args[i] == null) {
202-
throw new SQLException(
203-
"SqlRunner requires an instance of Null to represent typed null values for JDBC compatibility");
191+
throw new SQLException("SqlRunner requires an instance of Null to represent typed null values for JDBC compatibility");
204192
} else if (args[i] instanceof Null) {
205193
((Null) args[i]).getTypeHandler().setParameter(ps, i + 1, null, ((Null) args[i]).getJdbcType());
206194
} else {
@@ -214,9 +202,6 @@ private void setParameters(PreparedStatement ps, Object... args) throws SQLExcep
214202
}
215203
}
216204

217-
/**
218-
* ResultSet should't was closed in here,it should be closed in caller
219-
*/
220205
private List<Map<String, Object>> getResults(ResultSet rs) throws SQLException {
221206
List<Map<String, Object>> list = new ArrayList<>();
222207
List<String> columns = new ArrayList<>();

0 commit comments

Comments
 (0)