我使用下面的JDBC代码来调用需要Array输入的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();