【问题标题】:SCDF server dual database connection errorSCDF服务器双数据库连接错误
【发布时间】:2020-08-05 15:37:08
【问题描述】:

在我的 spring 批处理任务中,我配置了两个数据源,一个用于 oracle,另一个用于 h2。 H2 我用于批处理和任务执行表,oracle 用于批处理的真实数据。我能够从 ide 成功运行任务,但是当我从 SCDF 服务器运行它时,出现以下错误

Caused by: java.sql.SQLException: Unable to start the Universal Connection Pool: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-200]

问题是,为什么它还要连接到 H2 进行 oracle db 连接?

以下是我的数据库配置:

 @Bean(name = "OracleUniversalConnectionPool")
        public DataSource secondaryDataSource() {
            PoolDataSource pds = null;
            try {
                pds = PoolDataSourceFactory.getPoolDataSource();

                pds.setConnectionFactoryClassName(driverClassName);
                pds.setURL(url);
                pds.setUser(username);
                pds.setPassword(password);
                pds.setMinPoolSize(Integer.valueOf(minPoolSize));
                pds.setInitialPoolSize(10);
                pds.setMaxPoolSize(Integer.valueOf(maxPoolSize));

            } catch (SQLException ea) {
                 log.error("Error connecting to the database: ", ea.getMessage());
            }

            return pds;
        }
        
       @Bean(name = "batchDataSource")
       @Primary
        public DataSource dataSource() throws SQLException {
            final SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
            dataSource.setDriver(new org.h2.Driver());
            dataSource.setUrl("jdbc:h2:tcp://localhost:19092/mem:dataflow");
            dataSource.setUsername("sa");
            dataSource.setPassword("");
            return dataSource;
        }

【问题讨论】:

    标签: spring-batch spring-cloud-dataflow spring-cloud-task


    【解决方案1】:

    我解决了,问题是我用它来设置 oracle db 的值。

    spring.datasource.url: ******
    spring.datasource.username: ******
    

    它在 IDE 上运行良好,但是当我在 SCDF 服务器上运行它时,它被用于 SCDF 服务器数据库连接的默认属性覆盖。所以我刚刚将连接属性更新为:

    spring.datasource.oracle.url: ******
    spring.datasource.oracle.username: ******
    

    现在它按预期工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-01
      • 1970-01-01
      • 2021-09-15
      • 2017-12-16
      • 2013-11-07
      • 1970-01-01
      • 2019-10-05
      相关资源
      最近更新 更多