【发布时间】: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