public static String getGlobalVariable(DataSource dataSource, String variable) throws SQLException {
    try (Connection conn = dataSource.getConnection()) {
      try (
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(String.format("show global variables like '%s'", variable));
      ) {
        if (rs.next()) {
          return rs.getString(2);
        } else {
          return "";
        }
      }
    }
  }
public static String getGlobalVariable ( DataSource dataSource , String variable ) throws SQLException { try ( Connection conn = dataSource . getConnection ( ) ) { try ( Statement stmt = conn . createStatement ( ) ; ResultSet rs = stmt . executeQuery ( String . format ( "show global variables like '%s'" , variable ) ) ; ) { if ( rs . next ( ) ) { return rs . getString ( 2 ) ; } else { return "" ; } } } }
Get global variable value.
@param dataSource
@param variable
@return global variable value of empty string.
@throws SQLException