0
votes

In my spring batch task I have two datasources configured, one for oracle and another for h2. H2 I'm using for batch and task execution tables and oracle is for real data for batch processing. I'm able to successfully run the task from ide but when I run it from SCDF server I get following error

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]

Question is, why is it connecting to H2 for oracle db connection as well?

Following is my DB configuration:

 @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;
        }
1

1 Answers

0
votes

I got it resolved, problem was I was using this for setting values to oracle db.

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

It worked fine from IDE, but when I ran it on SCDF server it was overwritten by default properties being used for database connection of SCDF server. So I just updated the connection properties to :

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

And now it's working as expected.