java传集合到oracle的存储过程中

1.oracle先创建一个自定义的table类型(注:类型的名称必须要大写,否则会报无效名称)

CREATE OR REPLACE TYPE MAILIDTABLE AS TABLE OF NUMBER(1);

2.java方面( 注:这里必须要重新建立一个连接,不能使用com.jolbox.bonecp连接池里面的连接,至于其它连接池,我就没有试过了)

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl","user","pwd");
ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("MAILIDTABLE",connection);
ARRAY array_to_pass = new ARRAY(arrayDesc, connection, mIdList.toArray(new Integer[mIdList.size()]));
OracleCallableStatement statement = (OracleCallableStatement) connection.prepareCall("call MAIL_DELETE(?)");
statement.setArray(1, array_to_pass);



你可能感兴趣的:(oracle)