Skip to content

Commit c89d8ec

Browse files
committed
Polishing
Issue: SPR-12476 (cherry picked from commit 3b15849)
1 parent 7e07f3d commit c89d8ec

File tree

4 files changed

+156
-152
lines changed

4 files changed

+156
-152
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131
import org.springframework.jdbc.InvalidResultSetAccessException;
3232

3333
/**
34-
* Default implementation of Spring's {@link SqlRowSet} interface.
34+
* The default implementation of Spring's {@link SqlRowSet} interface, wrapping a
35+
* {@link java.sql.ResultSet}, catching any {@link SQLException}s and translating
36+
* them to a corresponding Spring {@link InvalidResultSetAccessException}.
3537
*
36-
* <p>This implementation wraps a {@code javax.sql.ResultSet}, catching any SQLExceptions
37-
* and translating them to the appropriate Spring {@link InvalidResultSetAccessException}.
38-
*
39-
* <p>The passed-in ResultSets should already be disconnected if the SqlRowSet is supposed
38+
* <p>The passed-in ResultSet should already be disconnected if the SqlRowSet is supposed
4039
* to be usable in a disconnected fashion. This means that you will usually pass in a
4140
* {@code javax.sql.rowset.CachedRowSet}, which implements the ResultSet interface.
4241
*
@@ -221,46 +220,47 @@ public byte getByte(String columnLabel) throws InvalidResultSetAccessException {
221220
}
222221

223222
/**
224-
* @see java.sql.ResultSet#getDate(int, java.util.Calendar)
223+
* @see java.sql.ResultSet#getDate(int)
225224
*/
226225
@Override
227-
public Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
226+
public Date getDate(int columnIndex) throws InvalidResultSetAccessException {
228227
try {
229-
return this.resultSet.getDate(columnIndex, cal);
228+
return this.resultSet.getDate(columnIndex);
230229
}
231230
catch (SQLException se) {
232231
throw new InvalidResultSetAccessException(se);
233232
}
234233
}
235234

236235
/**
237-
* @see java.sql.ResultSet#getDate(int)
236+
* @see java.sql.ResultSet#getDate(String)
238237
*/
239238
@Override
240-
public Date getDate(int columnIndex) throws InvalidResultSetAccessException {
239+
public Date getDate(String columnLabel) throws InvalidResultSetAccessException {
240+
return getDate(findColumn(columnLabel));
241+
}
242+
243+
/**
244+
* @see java.sql.ResultSet#getDate(int, Calendar)
245+
*/
246+
@Override
247+
public Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
241248
try {
242-
return this.resultSet.getDate(columnIndex);
249+
return this.resultSet.getDate(columnIndex, cal);
243250
}
244251
catch (SQLException se) {
245252
throw new InvalidResultSetAccessException(se);
246253
}
247254
}
255+
248256
/**
249-
* @see java.sql.ResultSet#getDate(String, java.util.Calendar)
257+
* @see java.sql.ResultSet#getDate(String, Calendar)
250258
*/
251259
@Override
252260
public Date getDate(String columnLabel, Calendar cal) throws InvalidResultSetAccessException {
253261
return getDate(findColumn(columnLabel), cal);
254262
}
255263

256-
/**
257-
* @see java.sql.ResultSet#getDate(String)
258-
*/
259-
@Override
260-
public Date getDate(String columnLabel) throws InvalidResultSetAccessException {
261-
return getDate(findColumn(columnLabel));
262-
}
263-
264264
/**
265265
* @see java.sql.ResultSet#getDouble(int)
266266
*/
@@ -302,6 +302,7 @@ public float getFloat(int columnIndex) throws InvalidResultSetAccessException {
302302
public float getFloat(String columnLabel) throws InvalidResultSetAccessException {
303303
return getFloat(findColumn(columnLabel));
304304
}
305+
305306
/**
306307
* @see java.sql.ResultSet#getInt(int)
307308
*/
@@ -345,47 +346,47 @@ public long getLong(String columnLabel) throws InvalidResultSetAccessException {
345346
}
346347

347348
/**
348-
* @see java.sql.ResultSet#getObject(int, java.util.Map)
349+
* @see java.sql.ResultSet#getObject(int)
349350
*/
350351
@Override
351-
public Object getObject(int i, Map<String, Class<?>> map) throws InvalidResultSetAccessException {
352+
public Object getObject(int columnIndex) throws InvalidResultSetAccessException {
352353
try {
353-
return this.resultSet.getObject(i, map);
354+
return this.resultSet.getObject(columnIndex);
354355
}
355356
catch (SQLException se) {
356357
throw new InvalidResultSetAccessException(se);
357358
}
358359
}
359360

360361
/**
361-
* @see java.sql.ResultSet#getObject(int)
362+
* @see java.sql.ResultSet#getObject(String)
362363
*/
363364
@Override
364-
public Object getObject(int columnIndex) throws InvalidResultSetAccessException {
365+
public Object getObject(String columnLabel) throws InvalidResultSetAccessException {
366+
return getObject(findColumn(columnLabel));
367+
}
368+
369+
/**
370+
* @see java.sql.ResultSet#getObject(int, Map)
371+
*/
372+
@Override
373+
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws InvalidResultSetAccessException {
365374
try {
366-
return this.resultSet.getObject(columnIndex);
375+
return this.resultSet.getObject(columnIndex, map);
367376
}
368377
catch (SQLException se) {
369378
throw new InvalidResultSetAccessException(se);
370379
}
371380
}
372381

373382
/**
374-
* @see java.sql.ResultSet#getObject(String, java.util.Map)
383+
* @see java.sql.ResultSet#getObject(String, Map)
375384
*/
376385
@Override
377-
public Object getObject(String columnLabel, Map<String, Class<?>> map) throws InvalidResultSetAccessException {
386+
public Object getObject(String columnLabel, Map<String, Class<?>> map) throws InvalidResultSetAccessException {
378387
return getObject(findColumn(columnLabel), map);
379388
}
380389

381-
/**
382-
* @see java.sql.ResultSet#getObject(String)
383-
*/
384-
@Override
385-
public Object getObject(String columnLabel) throws InvalidResultSetAccessException {
386-
return getObject(findColumn(columnLabel));
387-
}
388-
389390
/**
390391
* @see java.sql.ResultSet#getShort(int)
391392
*/
@@ -428,19 +429,6 @@ public String getString(String columnLabel) throws InvalidResultSetAccessExcepti
428429
return getString(findColumn(columnLabel));
429430
}
430431

431-
/**
432-
* @see java.sql.ResultSet#getTime(int, java.util.Calendar)
433-
*/
434-
@Override
435-
public Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
436-
try {
437-
return this.resultSet.getTime(columnIndex, cal);
438-
}
439-
catch (SQLException se) {
440-
throw new InvalidResultSetAccessException(se);
441-
}
442-
}
443-
444432
/**
445433
* @see java.sql.ResultSet#getTime(int)
446434
*/
@@ -454,14 +442,6 @@ public Time getTime(int columnIndex) throws InvalidResultSetAccessException {
454442
}
455443
}
456444

457-
/**
458-
* @see java.sql.ResultSet#getTime(String, java.util.Calendar)
459-
*/
460-
@Override
461-
public Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException {
462-
return getTime(findColumn(columnLabel), cal);
463-
}
464-
465445
/**
466446
* @see java.sql.ResultSet#getTime(String)
467447
*/
@@ -471,18 +451,26 @@ public Time getTime(String columnLabel) throws InvalidResultSetAccessException {
471451
}
472452

473453
/**
474-
* @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar)
454+
* @see java.sql.ResultSet#getTime(int, Calendar)
475455
*/
476456
@Override
477-
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
457+
public Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
478458
try {
479-
return this.resultSet.getTimestamp(columnIndex, cal);
459+
return this.resultSet.getTime(columnIndex, cal);
480460
}
481461
catch (SQLException se) {
482462
throw new InvalidResultSetAccessException(se);
483463
}
484464
}
485465

466+
/**
467+
* @see java.sql.ResultSet#getTime(String, Calendar)
468+
*/
469+
@Override
470+
public Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException {
471+
return getTime(findColumn(columnLabel), cal);
472+
}
473+
486474
/**
487475
* @see java.sql.ResultSet#getTimestamp(int)
488476
*/
@@ -497,19 +485,32 @@ public Timestamp getTimestamp(int columnIndex) throws InvalidResultSetAccessExce
497485
}
498486

499487
/**
500-
* @see java.sql.ResultSet#getTimestamp(String, java.util.Calendar)
488+
* @see java.sql.ResultSet#getTimestamp(String)
501489
*/
502490
@Override
503-
public Timestamp getTimestamp(String columnLabel, Calendar cal) throws InvalidResultSetAccessException {
504-
return getTimestamp(findColumn(columnLabel), cal);
491+
public Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessException {
492+
return getTimestamp(findColumn(columnLabel));
505493
}
506494

507495
/**
508-
* @see java.sql.ResultSet#getTimestamp(String)
496+
* @see java.sql.ResultSet#getTimestamp(int, Calendar)
509497
*/
510498
@Override
511-
public Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessException {
512-
return getTimestamp(findColumn(columnLabel));
499+
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
500+
try {
501+
return this.resultSet.getTimestamp(columnIndex, cal);
502+
}
503+
catch (SQLException se) {
504+
throw new InvalidResultSetAccessException(se);
505+
}
506+
}
507+
508+
/**
509+
* @see java.sql.ResultSet#getTimestamp(String, Calendar)
510+
*/
511+
@Override
512+
public Timestamp getTimestamp(String columnLabel, Calendar cal) throws InvalidResultSetAccessException {
513+
return getTimestamp(findColumn(columnLabel), cal);
513514
}
514515

515516

spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSetMetaData.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,17 +22,16 @@
2222
import org.springframework.jdbc.InvalidResultSetAccessException;
2323

2424
/**
25-
* Default implementation of Spring's SqlRowSetMetaData interface.
26-
* Used by ResultSetWrappingSqlRowSet.
25+
* The default implementation of Spring's {@link SqlRowSetMetaData} interface, wrapping
26+
* a {@link java.sql.ResultSetMetaData} instance, catching any {@link SQLException}s
27+
* and translating them to a corresponding Spring {@link InvalidResultSetAccessException}.
2728
*
28-
* <p>This implementation wraps a {@code javax.sql.ResultSetMetaData}
29-
* instance, catching any SQLExceptions and translating them to the
30-
* appropriate Spring DataAccessException.
29+
* <p>Used by {@link ResultSetWrappingSqlRowSet}.
3130
*
3231
* @author Thomas Risberg
3332
* @author Juergen Hoeller
3433
* @since 1.2
35-
* @see ResultSetWrappingSqlRowSet#getMetaData
34+
* @see ResultSetWrappingSqlRowSet#getMetaData()
3635
*/
3736
public class ResultSetWrappingSqlRowSetMetaData implements SqlRowSetMetaData {
3837

0 commit comments

Comments
 (0)