I know there are lot of solution for this in internet but nothing seems to work for me.

I have following entries for in the pom.xml file for my jdk11 app

 <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.9.RELEASE</version>
  </parent>
  <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>21.1.0.0</version>
 </dependency>
    <dependency>
        <groupId>com.oracle.database.ha</groupId>
        <artifactId>ons</artifactId>
         <version>21.1.0.0</version>
  </dependency>
        
 <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ucp</artifactId>
            <version>21.1.0.0</version>
</dependency>

I am using connection pool with config as follows

 platform: oracle
   url: jdbc:oracle:thin:@localhost:1521:TEST
   connectionFactoryClassName: oracle.jdbc.pool.OracleDataSource
   fastConnectionFailoverEnabled: true
   username: test
   password: test
   initialPoolSize: 3
   minPoolSize: 0
   maxPoolSize: 12
   inactivityTimeout: 300
   queryTimeout: 600
   validateConnectionOnBorrow: true

I am only querying for table no add or update to oracle record, something like this

PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource();
 @Bean
public DaoSpringJdbcImpl listenerDAO(final DataSource dataSource ) {
            NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource );
            DaoSpringJdbcImpl listenerDAO = new DaoSpringJdbcImpl(template);
            return listenerDAO;
        }

 public class DaoSpringJdbcImpl {
    private NamedParameterJdbcTemplate jdbcTemplate;
 
  public  DaoSpringJdbcImpl(NamedParameterJdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }


public void method() {
 List<String> results = jdbcTemplate.query(SQL_QUERY, params,
          new RowMapper<String>()
     {
          public String mapRow(ResultSet rs, int rowNum) throws SQLException
                    {  return rs.getString(0)}
    }
}

so everytime my application queries it opens up new cursor and never close it ultimately resulting to open cursor exception

PS I tried adding env property spring.jdbc.getParameterType.ignore = true which didnt work

0

There are 0 best solutions below