|
46 | 46 | import org.springframework.jdbc.support.JdbcAccessor;
|
47 | 47 | import org.springframework.jdbc.support.JdbcUtils;
|
48 | 48 | import org.springframework.jdbc.support.KeyHolder;
|
49 |
| -import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor; |
50 | 49 | import org.springframework.jdbc.support.rowset.SqlRowSet;
|
51 | 50 | import org.springframework.util.Assert;
|
52 | 51 | import org.springframework.util.LinkedCaseInsensitiveMap;
|
@@ -104,9 +103,6 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
104 | 103 | private static final String RETURN_UPDATE_COUNT_PREFIX = "#update-count-";
|
105 | 104 |
|
106 | 105 |
|
107 |
| - /** Custom NativeJdbcExtractor */ |
108 |
| - private NativeJdbcExtractor nativeJdbcExtractor; |
109 |
| - |
110 | 106 | /** If this variable is false, we will throw exceptions on SQL warnings */
|
111 | 107 | private boolean ignoreWarnings = true;
|
112 | 108 |
|
@@ -182,23 +178,6 @@ public JdbcTemplate(DataSource dataSource, boolean lazyInit) {
|
182 | 178 | }
|
183 | 179 |
|
184 | 180 |
|
185 |
| - /** |
186 |
| - * Set a NativeJdbcExtractor to extract native JDBC objects from wrapped handles. |
187 |
| - * Useful if native Statement and/or ResultSet handles are expected for casting |
188 |
| - * to database-specific implementation classes, but a connection pool that wraps |
189 |
| - * JDBC objects is used (note: <i>any</i> pool will return wrapped Connections). |
190 |
| - */ |
191 |
| - public void setNativeJdbcExtractor(NativeJdbcExtractor extractor) { |
192 |
| - this.nativeJdbcExtractor = extractor; |
193 |
| - } |
194 |
| - |
195 |
| - /** |
196 |
| - * Return the current NativeJdbcExtractor implementation. |
197 |
| - */ |
198 |
| - public NativeJdbcExtractor getNativeJdbcExtractor() { |
199 |
| - return this.nativeJdbcExtractor; |
200 |
| - } |
201 |
| - |
202 | 181 | /**
|
203 | 182 | * Set whether or not we want to ignore SQLWarnings.
|
204 | 183 | * <p>Default is "true", swallowing and logging all warnings. Switch this flag
|
@@ -341,15 +320,8 @@ public <T> T execute(ConnectionCallback<T> action) throws DataAccessException {
|
341 | 320 |
|
342 | 321 | Connection con = DataSourceUtils.getConnection(getDataSource());
|
343 | 322 | try {
|
344 |
| - Connection conToUse = con; |
345 |
| - if (this.nativeJdbcExtractor != null) { |
346 |
| - // Extract native JDBC Connection, castable to OracleConnection or the like. |
347 |
| - conToUse = this.nativeJdbcExtractor.getNativeConnection(con); |
348 |
| - } |
349 |
| - else { |
350 |
| - // Create close-suppressing Connection proxy, also preparing returned Statements. |
351 |
| - conToUse = createConnectionProxy(con); |
352 |
| - } |
| 323 | + // Create close-suppressing Connection proxy, also preparing returned Statements. |
| 324 | + Connection conToUse = createConnectionProxy(con); |
353 | 325 | return action.doInConnection(conToUse);
|
354 | 326 | }
|
355 | 327 | catch (SQLException ex) {
|
@@ -394,18 +366,9 @@ public <T> T execute(StatementCallback<T> action) throws DataAccessException {
|
394 | 366 | Connection con = DataSourceUtils.getConnection(getDataSource());
|
395 | 367 | Statement stmt = null;
|
396 | 368 | try {
|
397 |
| - Connection conToUse = con; |
398 |
| - if (this.nativeJdbcExtractor != null && |
399 |
| - this.nativeJdbcExtractor.isNativeConnectionNecessaryForNativeStatements()) { |
400 |
| - conToUse = this.nativeJdbcExtractor.getNativeConnection(con); |
401 |
| - } |
402 |
| - stmt = conToUse.createStatement(); |
| 369 | + stmt = con.createStatement(); |
403 | 370 | applyStatementSettings(stmt);
|
404 |
| - Statement stmtToUse = stmt; |
405 |
| - if (this.nativeJdbcExtractor != null) { |
406 |
| - stmtToUse = this.nativeJdbcExtractor.getNativeStatement(stmt); |
407 |
| - } |
408 |
| - T result = action.doInStatement(stmtToUse); |
| 371 | + T result = action.doInStatement(stmt); |
409 | 372 | handleWarnings(stmt);
|
410 | 373 | return result;
|
411 | 374 | }
|
@@ -456,11 +419,7 @@ public T doInStatement(Statement stmt) throws SQLException {
|
456 | 419 | ResultSet rs = null;
|
457 | 420 | try {
|
458 | 421 | rs = stmt.executeQuery(sql);
|
459 |
| - ResultSet rsToUse = rs; |
460 |
| - if (nativeJdbcExtractor != null) { |
461 |
| - rsToUse = nativeJdbcExtractor.getNativeResultSet(rs); |
462 |
| - } |
463 |
| - return rse.extractData(rsToUse); |
| 422 | + return rse.extractData(rs); |
464 | 423 | }
|
465 | 424 | finally {
|
466 | 425 | JdbcUtils.closeResultSet(rs);
|
@@ -619,18 +578,9 @@ public <T> T execute(PreparedStatementCreator psc, PreparedStatementCallback<T>
|
619 | 578 | Connection con = DataSourceUtils.getConnection(getDataSource());
|
620 | 579 | PreparedStatement ps = null;
|
621 | 580 | try {
|
622 |
| - Connection conToUse = con; |
623 |
| - if (this.nativeJdbcExtractor != null && |
624 |
| - this.nativeJdbcExtractor.isNativeConnectionNecessaryForNativePreparedStatements()) { |
625 |
| - conToUse = this.nativeJdbcExtractor.getNativeConnection(con); |
626 |
| - } |
627 |
| - ps = psc.createPreparedStatement(conToUse); |
| 581 | + ps = psc.createPreparedStatement(con); |
628 | 582 | applyStatementSettings(ps);
|
629 |
| - PreparedStatement psToUse = ps; |
630 |
| - if (this.nativeJdbcExtractor != null) { |
631 |
| - psToUse = this.nativeJdbcExtractor.getNativePreparedStatement(ps); |
632 |
| - } |
633 |
| - T result = action.doInPreparedStatement(psToUse); |
| 583 | + T result = action.doInPreparedStatement(ps); |
634 | 584 | handleWarnings(ps);
|
635 | 585 | return result;
|
636 | 586 | }
|
@@ -690,11 +640,7 @@ public T doInPreparedStatement(PreparedStatement ps) throws SQLException {
|
690 | 640 | pss.setValues(ps);
|
691 | 641 | }
|
692 | 642 | rs = ps.executeQuery();
|
693 |
| - ResultSet rsToUse = rs; |
694 |
| - if (nativeJdbcExtractor != null) { |
695 |
| - rsToUse = nativeJdbcExtractor.getNativeResultSet(rs); |
696 |
| - } |
697 |
| - return rse.extractData(rsToUse); |
| 643 | + return rse.extractData(rs); |
698 | 644 | }
|
699 | 645 | finally {
|
700 | 646 | JdbcUtils.closeResultSet(rs);
|
@@ -1070,17 +1016,9 @@ public <T> T execute(CallableStatementCreator csc, CallableStatementCallback<T>
|
1070 | 1016 | Connection con = DataSourceUtils.getConnection(getDataSource());
|
1071 | 1017 | CallableStatement cs = null;
|
1072 | 1018 | try {
|
1073 |
| - Connection conToUse = con; |
1074 |
| - if (this.nativeJdbcExtractor != null) { |
1075 |
| - conToUse = this.nativeJdbcExtractor.getNativeConnection(con); |
1076 |
| - } |
1077 |
| - cs = csc.createCallableStatement(conToUse); |
| 1019 | + cs = csc.createCallableStatement(con); |
1078 | 1020 | applyStatementSettings(cs);
|
1079 |
| - CallableStatement csToUse = cs; |
1080 |
| - if (this.nativeJdbcExtractor != null) { |
1081 |
| - csToUse = this.nativeJdbcExtractor.getNativeCallableStatement(cs); |
1082 |
| - } |
1083 |
| - T result = action.doInCallableStatement(csToUse); |
| 1021 | + T result = action.doInCallableStatement(cs); |
1084 | 1022 | handleWarnings(cs);
|
1085 | 1023 | return result;
|
1086 | 1024 | }
|
@@ -1274,22 +1212,18 @@ protected Map<String, Object> processResultSet(ResultSet rs, ResultSetSupporting
|
1274 | 1212 | }
|
1275 | 1213 | Map<String, Object> returnedResults = new HashMap<>();
|
1276 | 1214 | try {
|
1277 |
| - ResultSet rsToUse = rs; |
1278 |
| - if (this.nativeJdbcExtractor != null) { |
1279 |
| - rsToUse = this.nativeJdbcExtractor.getNativeResultSet(rs); |
1280 |
| - } |
1281 | 1215 | if (param.getRowMapper() != null) {
|
1282 | 1216 | RowMapper rowMapper = param.getRowMapper();
|
1283 |
| - Object result = (new RowMapperResultSetExtractor(rowMapper)).extractData(rsToUse); |
| 1217 | + Object result = (new RowMapperResultSetExtractor(rowMapper)).extractData(rs); |
1284 | 1218 | returnedResults.put(param.getName(), result);
|
1285 | 1219 | }
|
1286 | 1220 | else if (param.getRowCallbackHandler() != null) {
|
1287 | 1221 | RowCallbackHandler rch = param.getRowCallbackHandler();
|
1288 |
| - (new RowCallbackHandlerResultSetExtractor(rch)).extractData(rsToUse); |
| 1222 | + (new RowCallbackHandlerResultSetExtractor(rch)).extractData(rs); |
1289 | 1223 | returnedResults.put(param.getName(), "ResultSet returned from stored procedure was processed");
|
1290 | 1224 | }
|
1291 | 1225 | else if (param.getResultSetExtractor() != null) {
|
1292 |
| - Object result = param.getResultSetExtractor().extractData(rsToUse); |
| 1226 | + Object result = param.getResultSetExtractor().extractData(rs); |
1293 | 1227 | returnedResults.put(param.getName(), result);
|
1294 | 1228 | }
|
1295 | 1229 | }
|
|
0 commit comments