2 回答
TA贡献1772条经验 获得超5个赞
您可以将 JDBC 连接属性设置"oracle.jdbc.createDescriptorUseCurrentSchemaForSchemaName"
为"true"
,然后将架构切换为"job_runner"
( ALTER SESSION SET CURRENT_SCHEMA=job_runner
) 并TEST_PACKAGE_FOR_SP.SOME_TABLE_TYP
用于 typeTableList。
TA贡献1785条经验 获得超4个赞
方法之一:
package testproject;
import java.sql.Array;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Types;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import oracle.sql.ARRAY;
import oracle.jdbc.OracleCallableStatement;
import oracle.sql.ArrayDescriptor;
public class MainClass {
public MainClass() {
super();
}
public static void main(String[] args) {
MainClass mainClass = new MainClass();
Connection conn = null;
ArrayDescriptor des = null;
try {
Object[] obj1 = { 1, "2017-01-01 10:12:10", 200 };
Object[] obj2 = { 2, "2017-06-01 10:12:10", 600 };
Object[] obj3 = { 3, "2017-08-01 10:12:10", 990 };
conn =
DriverManager.getConnection("jdbc:oracle:thin:@<DB_HOST>",
"<user>", "<pass>");
try {
des = ArrayDescriptor.createDescriptor("AJ_TEST_OBJ_TBL", conn);
} catch (SQLException e) {
System.out.println("Arraydesc went wrong.");
System.out.println(e.getStackTrace());
}
ARRAY nArray =
new ARRAY(des, conn, new Object[] { obj1, obj2, obj3 });
OracleCallableStatement pstmt =
(OracleCallableStatement)conn.prepareCall("begin
aj_test_array_pck.print_tbl_parameters(?,?); end;");
pstmt.setArray(1, nArray);
pstmt.registerOutParameter(2, Types.VARCHAR);
pstmt.execute();
String status = pstmt.getString(2);
System.out.println("Status: " + status);
pstmt.close();
conn.close();
} catch (SQLException e) {
System.out.println("Oops with select");
System.out.println(e.getStackTrace());
} catch (ClassNotFoundException e) {
System.out.println("Oops with class");
}
}
}
其中“AJ_TEST_OBJ_TBL”是一个 SQL 类型的对象。
添加回答
举报