code: public String query(String query) {
          try {
              Connection conn = this.tx().getConnection();
              ObjectNode result = this.mapper.createObjectNode();
              ArrayNode dataNode = this.mapper.createArrayNode();
              ArrayNode metaNode = this.mapper.createArrayNode();
              Statement statement = conn.createStatement();
              if (logger.isDebugEnabled()) {
                  logger.debug(query);
              }
              ResultSet rs = statement.executeQuery(query);
              ResultSetMetaData rsmd = rs.getMetaData();
              boolean first = true;
              while (rs.next()) {
                  int numColumns = rsmd.getColumnCount();
                  ObjectNode obj = this.mapper.createObjectNode();
                  for (int i = 1; i < numColumns + 1; i++) {
                      String columnName = rsmd.getColumnLabel(i);
                      int type = rsmd.getColumnType(i);
                      //make sure to obtain array using getArray()
                      //At least in H2, this makes a difference...
                      Object o = type == Types.ARRAY ? rs.getArray(i) : rs.getObject(i);
                      this.sqlDialect.putJsonObject(obj, columnName, type, o);
                      if (first) {
                          this.sqlDialect.putJsonMetaObject(this.mapper, metaNode, columnName, type, o);
                      }
                  }
                  first = false;
                  dataNode.add(obj);
              }
              result.set("data", dataNode);
              result.set("meta", metaNode);
              return result.toString();
          } catch (SQLException e) {
              throw new RuntimeException(e);
          } finally {
              this.tx().rollback();
          }
      }
docs: This is executes a sql query and returns the result as a json string.
  
  @param query The sql to executeRegularQuery.
  @return The query result as json.