swagle commented on a change in pull request #221: HDDS-2538. Fix issues found
in DatabaseHelper.
URL: https://github.com/apache/hadoop-ozone/pull/221#discussion_r348673936
##########
File path:
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/audit/parser/common/DatabaseHelper.java
##########
@@ -213,27 +223,24 @@ public static String executeTemplate(String dbName,
String template)
private static String executeStatement(String dbName, String sql)
throws SQLException {
StringBuilder result = new StringBuilder();
- ResultSet rs = null;
- Statement st = null;
- ResultSetMetaData rsm = null;
- try(Connection connection = getConnection(dbName)) {
- //loadProperties();
-
- if(connection != null){
- st = connection.createStatement();
- rs = st.executeQuery(sql);
- if(rs != null) {
- rsm = rs.getMetaData();
- int cols = rsm.getColumnCount();
- while(rs.next()){
- for(int index =1; index<=cols; index++){
- result.append(rs.getObject(index) + "\t");
+ ResultSetMetaData rsm;
+ try (Connection connection = getConnection(dbName)) {
+ if (connection != null){
+ try (Statement st = connection.createStatement()) {
+ try (ResultSet rs = st.executeQuery(sql)) {
Review comment:
Ahh, ok I see what you mean, nm!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]