DaanHoogland commented on a change in pull request #5588:
URL: https://github.com/apache/cloudstack/pull/5588#discussion_r782291755
##########
File path: framework/db/src/main/java/com/cloud/utils/db/DbUtil.java
##########
@@ -282,4 +282,25 @@ public static void closeConnection(final Connection
connection) {
closeAutoCloseable(connection, "exception while close connection.");
}
+ public static Map<String, String> getDbInfo(String type, String ... var) {
+ String vars = String.join(",", var);
+ Map<String, String> result = new HashMap<>();
+ String sql = String.format("SHOW %s WHERE
FIND_IN_SET(Variable_name,?)",type);
+ final TransactionLegacy txn = TransactionLegacy.open("metrics");
+ try {
+ PreparedStatement pstmt = txn.prepareAutoCloseStatement(sql);
+ pstmt.setString(1, vars);
+ final ResultSet rs = pstmt.executeQuery();
+ while (rs.next()) {
+ String variableName = rs.getString("Variable_name");
+ String value = rs.getString("value");
+ result.put(variableName, value);
+ }
+ } catch (SQLException e) {
+ LOGGER.error("failed to get the database status: " +
e.getLocalizedMessage());
+ LOGGER.debug("failed to get the database status", e);
Review comment:
done on purpose to keep the stack trace out of the logs in `error` level
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]