0

I have the following code which Spring can't resolve. What's the step I can take for this?

public JdbcTemplate jdbcTemplate() {

        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        SimpleNativeJdbcExtractor simpleNativeJdbcExtractor = new SimpleNativeJdbcExtractor() {
            @Override
            public Connection getNativeConnection(Connection con) throws SQLException {
                con.setSchema(TenantContext.getCurrentTenant());
                return super.getNativeConnection(con);
            }

            @Override
            public Connection getNativeConnectionFromStatement(Statement stmt) throws SQLException {
                return super.getNativeConnectionFromStatement(stmt);
            }
        };
        simpleNativeJdbcExtractor.setNativeConnectionNecessaryForNativeStatements(true);
        jdbcTemplate.setNativeJdbcExtractor(simpleNativeJdbcExtractor);

        return jdbcTemplate;
    }

I this is the Spring boot I use for the app and also tried with an earlier version:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.4.RELEASE</version>
<!--        <version>1.5.11.RELEASE</version>-->
        <relativePath/>
    </parent>

Thank you.

Arefe
  • 11,321
  • 18
  • 114
  • 168
  • 1
    What Spring version do you use? Spring Boot? – Nikolas Charalambidis Nov 09 '20 at 17:20
  • It's been [removed ages ago](https://stackoverflow.com/questions/47397238/replacement-for-jdbc-support-nativejdbc-remove-in-spring-5). – Kayaman Nov 09 '20 at 17:26
  • 2
    The last version with `SimpleNativeJdbcExtractor ` is Spring Framework [5.0.0.M4](https://docs.spring.io/spring-framework/docs/5.0.0.M4/javadoc-api/) and it is gone as of [5.0.0.M5](https://docs.spring.io/spring-framework/docs/5.0.0.M5/javadoc-api/).Your version of Spring Boot `2.3.4.RELEASE` uses Spring Framework `5.2.9.RELEASE`, therefore such class is correctly unavailable. – Nikolas Charalambidis Nov 09 '20 at 17:33
  • @NikolasCharalambidis you deserve a point for all that technical correctness. – Kayaman Nov 09 '20 at 17:36

0 Answers0