private DataSourceInstance findDataSourceInstanceDetails()

in src/main/java/org/apache/fineract/cn/core/data/jpa/local/LocalRoutingDataSource.java [108:132]


  private DataSourceInstance findDataSourceInstanceDetails(final String dataSourceIdentifier) {
    this.logger.debug("Fetching data source details for '{}'.", dataSourceIdentifier);
    final String query = "SELECT driver_class, jdbc_url, username, password FROM data_source_instances WHERE identifier = ? ";
    final DataSource managementDataSource = this.getManagementDataSource();
    try (
        final Connection conn = managementDataSource.getConnection();
        final PreparedStatement pstmt = conn.prepareCall(query)) {
      pstmt.setString(1, dataSourceIdentifier);
      try (final ResultSet rset = pstmt.executeQuery()) {
        if (rset.next()) {
          final DataSourceInstance dataSourceInstance = new DataSourceInstance();
          dataSourceInstance.setDriverClass(rset.getString(1));
          dataSourceInstance.setJdbcUrl(rset.getString(2));
          dataSourceInstance.setUsername(rset.getString(3));
          dataSourceInstance.setPassword(rset.getString(4));
          return dataSourceInstance;
        }
      } catch (final SQLException sqlex) {
        throw new IllegalStateException(sqlex.getMessage());
      }
    } catch (final SQLException sqlex) {
      throw new IllegalStateException(sqlex.getMessage());
    }
    throw new IllegalStateException("No data source instance found for identifier '" + dataSourceIdentifier + "'.");
  }