|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | *
|
4 | 4 | * This program is free software; you can redistribute it and/or modify it under
|
5 | 5 | * the terms of the GNU General Public License, version 2.0, as published by the
|
|
29 | 29 |
|
30 | 30 | package com.mysql.cj.jdbc.interceptors;
|
31 | 31 |
|
| 32 | +import java.sql.ResultSet; |
32 | 33 | import java.sql.SQLException;
|
| 34 | +import java.sql.Statement; |
33 | 35 | import java.util.HashMap;
|
34 | 36 | import java.util.Map;
|
35 | 37 | import java.util.Properties;
|
|
40 | 42 | import com.mysql.cj.exceptions.ExceptionFactory;
|
41 | 43 | import com.mysql.cj.interceptors.QueryInterceptor;
|
42 | 44 | import com.mysql.cj.jdbc.JdbcConnection;
|
43 |
| -import com.mysql.cj.jdbc.util.ResultSetUtil; |
44 | 45 | import com.mysql.cj.log.Log;
|
45 | 46 | import com.mysql.cj.protocol.Resultset;
|
46 | 47 | import com.mysql.cj.protocol.ServerSession;
|
@@ -75,23 +76,14 @@ public <T extends Resultset> T postProcess(Supplier<String> sql, Query intercept
|
75 | 76 | }
|
76 | 77 |
|
77 | 78 | private void populateMapWithSessionStatusValues(Map<String, String> toPopulate) {
|
78 |
| - java.sql.Statement stmt = null; |
79 |
| - java.sql.ResultSet rs = null; |
80 |
| - |
81 | 79 | try {
|
82 |
| - try { |
| 80 | + try (Statement stmt = this.connection.createStatement()) { |
83 | 81 | toPopulate.clear();
|
84 | 82 |
|
85 |
| - stmt = this.connection.createStatement(); |
86 |
| - rs = stmt.executeQuery("SHOW SESSION STATUS"); |
87 |
| - ResultSetUtil.resultSetToMap(toPopulate, rs); |
88 |
| - } finally { |
89 |
| - if (rs != null) { |
90 |
| - rs.close(); |
91 |
| - } |
92 |
| - |
93 |
| - if (stmt != null) { |
94 |
| - stmt.close(); |
| 83 | + try (ResultSet rs = stmt.executeQuery("SHOW SESSION STATUS")) { |
| 84 | + while (rs.next()) { |
| 85 | + toPopulate.put(rs.getString(1), rs.getString(2)); |
| 86 | + } |
95 | 87 | }
|
96 | 88 | }
|
97 | 89 | } catch (SQLException ex) {
|
|
0 commit comments