如何修复已弃用的oracle.sql.ArrayDescriptor,oracle.sql.STRUCT和oracle.sql.StructDescriptor
2022-09-04 05:46:29
我使用以下 JDBC 代码来调用采用数组输入的 Oracle 存储过程。
但以下三个类已被弃用。如何替换这个?
import oracle.sql.ArrayDescriptor;
import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;
Java 代码
Object[] reportArray = new Object[3];
STRUCT[] struct = new STRUCT[reports.size()];
ArrayDescriptor arrayDescriptor = new ArrayDescriptor(new SQLName("T_REPORT_TABLE", (OracleConnection) connection), connection);
StructDescriptor structDescriptor = StructDescriptor.createDescriptor("R_REPORT_OBJECT", connection);
int arrayIndex = 0;
for (Report data : reports) {
reportArray[0] = data.getXXX();
reportArray[1] = data.getYYY();
reportArray[2] = data.getZZZ();
struct[arrayIndex++] = new STRUCT(structDescriptor, connection, reportArray);
}
oracle.sql.ARRAY reportsArray = new oracle.sql.ARRAY(arrayDescriptor, connection, struct);
callableStatement.setArray("T_REPORT_IN", reportsArray);
callableStatement.executeUpdate();