コード例 #1
0
  /**
   * Ping the DB and get some basic info
   *
   * @return
   * @throws ConnectionException
   */
  @RequestMapping(value = "/pingDb", produces = "application/json")
  public ConnectionInfo testDbConnection() throws ConnectionException {
    final ConnectionInfo info = new ConnectionInfo();

    try {

      JdbcUtils.extractDatabaseMetaData(
          appConfig.getDataSource(),
          new DatabaseMetaDataCallback() {
            public Object processMetaData(DatabaseMetaData databaseMetaData)
                throws SQLException, MetaDataAccessException {
              log.info(databaseMetaData.toString());
              info.setVendor(databaseMetaData.getDatabaseProductName());
              info.setUsername(databaseMetaData.getUserName());
              info.setVersion(
                  databaseMetaData.getDatabaseMajorVersion()
                      + "."
                      + databaseMetaData.getDatabaseMinorVersion());
              info.setConnected(true);
              return null;
            }
          });
    } catch (MetaDataAccessException e) {
      // e.printStackTrace();
      throw new ConnectionException(e.getMessage());
    }

    return info;
  }
コード例 #2
0
  /**
   * Ping promo planner and get some basic info
   *
   * @return
   * @throws ConnectionException
   */
  @RequestMapping(value = "/pingAPI", produces = "application/json")
  public ConnectionInfo testAPIConnection() throws ConnectionException {

    try {
      appConfig.getPromoPlanner().ping();
    } catch (Exception e) {
      throw new ConnectionException(e.getMessage());
    }

    return new ConnectionInfo(environment.getProperty("ppdb.username"), "JDA", "9.0", true);
  }
コード例 #3
0
 @Secured("ROLE_ADMIN")
 @RequestMapping(value = "/ppparams", produces = "application/json")
 public String getPromoPlannerParams() throws ConnectionException {
   return new JSONObject(appConfig.getCachedConfigMap()).toString();
 }