HikariDataSource:HikariPool-0-连接不可用,请求在30000毫秒后超时

时间:2018-10-17 11:41:37

标签: sql oracle spring-boot cloudfoundry pivotal-cloud-foundry

我正在处理一个包含两个数据库连接的springboot应用程序。

一个是Mysql,另一个是Oracle..Mysql连接和数据源bean(MariaDB)没问题。.但是,当涉及到Oracle(这是Cloud Foundry中部署的外部数据库)时,会出现问题。 / p>

我的CloudConfig文件如下所示,

private DataSource createDataSource(final String serviceName, final Cloud cloud) {
        final ExternalDependency externalDependency = cloud
                .getServiceConnector(serviceName, ExternalDependency.class, null);
        if (externalDependency == null) {
            throw new InvalidConfigurationException(
                    String.format("Error getting ServiceConnector for External Dependency with serviceName=[%s]", serviceName)
                    );
        }
        HikariDataSource dataSource = null;

        try {
            final HikariConfig config = new HikariConfig();
            config.setDriverClassName(requiredStringProperty("driverClassName", externalDependency, serviceName));
            config.setJdbcUrl(requiredStringProperty("jdbcUrl", externalDependency, serviceName));
            config.setUsername(requiredStringProperty("username", externalDependency, serviceName));
            config.setPassword(requiredStringProperty("password", externalDependency, serviceName));
            config.setConnectionTestQuery(requiredStringProperty("connectionTestQuery", externalDependency, serviceName));
            config.setMinimumIdle(intProperty("minimumIdle", externalDependency, serviceName, 1));
            config.setMaximumPoolSize(intProperty("maximumPoolSize", externalDependency, serviceName, 5));

            LOG.info("config values : {}, {}, {} ,{}, {}, {}, {}", 
                    config.getDriverClassName(), 
                    config.getJdbcUrl(), 
                    config.getUsername(), 
                    config.getPassword(), 
                    config.getConnectionTestQuery(),
                    config.getMinimumIdle(), 
                    config.getMaximumPoolSize());

            LOG.info("Before HikariDatasource");
            dataSource = new HikariDataSource(config);
            LOG.info("After HikariDatasource");

            /*OracleDataSource dataSource1 = new OracleDataSource();

            dataSsetDriverClassName(requiredStringProperty("driverClassName", externalDependency, serviceName));
            dataSource1.setJdbcUrl(requiredStringProperty("jdbcUrl", externalDependency, serviceName));
            dataSource1.setUsername(requiredStringProperty("username", externalDependency, serviceName));
            dataSource.
            */
            String dataSourceDetails = dataSourceDetails(dataSource);
            LOG.info("Available DataSource oracleDb: [{}]", dataSourceDetails);

        } catch (Exception e) {

            LOG.info("Info For The Error : {}", e.getMessage());

            LOG.info("{}", e);
        }
        return dataSource;

我能够获得所有详细信息。.我已经检查了所有连接..它们的运行状况良好。

但是当我在Cloud Foundry中部署jar时,出现以下问题,请在下面找到堆栈跟踪,

Caused by: java.sql.SQLTransientConnectionException: HikariPool-0 - Connection is not available, request timed out after 30000ms.
2018-10-17T16:45:10.290+05:30 [APP/PROC/WEB/0] [OUT] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:196) ~[HikariCP-2.4.2.jar!/:na]
2018-10-17T16:45:10.290+05:30 [APP/PROC/WEB/0] [OUT] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:148) ~[HikariCP-2.4.2.jar!/:na]
2018-10-17T16:45:10.290+05:30 [APP/PROC/WEB/0] [OUT] at com.zaxxer.hikari.pool.HikariPool.initializeConnections(HikariPool.java:519) ~[HikariCP-2.4.2.jar!/:na]
2018-10-17T16:45:10.290+05:30 [APP/PROC/WEB/0] [OUT] ... 122 common frames omitted
2018-10-17T16:45:10.290+05:30 [APP/PROC/WEB/0] [OUT] Caused by: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
2018-10-17T16:45:10.291+05:30 [APP/PROC/WEB/0] [OUT] at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:774) ~[ojdbc8-12.2.0.1.jar!/:12.2.0.1.0]
2018-10-17T16:45:10.291+05:30 [APP/PROC/WEB/0] [OUT] at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688) ~[ojdbc8-12.2.0.1.jar!/:12.2.0.1.0]

有人可以帮忙吗?我从2天开始就遇到了这个问题!

0 个答案:

没有答案