我正在升级一个使用连接池的类。特别是界面:
oracle.jdbc.OracleConnection
现在这个接口有很多被弃用的方法。我只是想知道这个界面还有其他选择,所以我不会得到通常的:
The type XXXX must implement the inherited abstract method OracleConnection.getJavaObject(String)
等等等等。以前,代码通过 SupressWarning 注释进行检查。我不喜欢那样。有什么办法可以克服这个吗?还是注释是唯一的方法?
我的 maven 依赖导入就像,如果这有任何帮助:
<!-- 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();
}
.
.
.
.