Oracle连接已弃用的方法问题

我正在升级使用连接池的类。特别是界面:


oracle.jdbc.OracleConnection

现在这个接口有很多不推荐使用的方法。我只是想知道这个界面还有其他替代方案,所以我不会得到通常的:


The type XXXX must implement the inherited abstract method OracleConnection.getJavaObject(String)

等等。以前,代码与“警告”注释保持一致。我不喜欢这样。有没有办法克服这一点?还是注释是唯一的方法?


我的专家依赖导入是这样的,如果这有任何帮助的话:


<!-- https://mvnrepository.com/artifact/com.oracle/ojdbc6 -->

        <dependency>

            <groupId>com.oracle</groupId>

            <artifactId>ojdbc6</artifactId>

            <version>11.2.0.4</version>

        </dependency>


        <!-- https://mvnrepository.com/artifact/com.oracle/ucp -->

        <dependency>

            <groupId>com.oracle.jdbc</groupId>

            <artifactId>ucp</artifactId>

            <version>12.2.0.1</version>

        </dependency>

添加代码(该类仅覆盖了OracleConnection接口中的所有方法),我很确定它没有被大量使用,但由于它是一个旧代码,不能肯定地说。


@SuppressWarnings("deprecation")

public class APPDBConnection implements OracleConnection {


    private OracleConnection connection;


    public APPDBConnection (OracleConnection connection) {

        super();

        this.connection = connection;

    }


    @Override

    public <T> T unwrap(Class<T> iface) throws SQLException {

        return connection.unwrap(iface);

    }


    @Override

    public boolean isWrapperFor(Class<?> iface) throws SQLException {

        return connection.isWrapperFor(iface);

    }


    @Override

    public void clearWarnings() throws SQLException {

        connection.clearWarnings();

    }

.

.

.

.


交互式爱情
浏览 125回答 1
1回答

慕娘9325324

据我所知,没有其他选择,特别是对于甲骨文11g。OracleConnection您确定绝对需要了解吗?您基本上是将实现绑定到特定的提供程序。OracleConnection您只提供哪些方法才能有效使用?考虑针对接口进行编程。OracleConnectionjava.sql.Connectionpublic class APPDBConnection implements Connection {&nbsp; &nbsp; private final Connection connection;&nbsp; &nbsp; public APPDBConnection(final Connection connection) {&nbsp; &nbsp; &nbsp; &nbsp; this.connection = connection;&nbsp; &nbsp; }只需传入已构造的 .在那之后,您将不再知道它,恕我直言,这是界面的目标。OracleConnection
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java