java 调用存储过程 传入和返回全部是自定义数组

String result=""; Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.19.133:1521:gbk10g", "wzh", "wzh"); long start = System.currentTimeMillis(); con.setAutoCommit(false); CallableStatement cstmt = con.prepareCall("{ ? = call getRowMd5(?) }"); //设置返回的数组类型 cstmt.registerOutParameter(1,OracleTypes.ARRAY,"TABLE_DM"); //开始设置传入数组 List list=new ArrayList(); for(int i=1;i<=1000;i++){ list.add(i+""); } ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("EMPARRAY", con); ARRAY array = new ARRAY(arrayDesc, con, list.toArray()); cstmt.setArray(2, array); //结束设置传入数组 cstmt.execute(); con.commit(); //开始处理传入数组 Array aa = cstmt.getArray(1); Object[] obj = (Object[]) aa.getArray(); for (int i = 0; i < obj.length; i++) { STRUCT struct = (STRUCT) obj[i]; Datum[] dt = struct.getOracleAttributes(); for (int n = 0; n < dt.length; n++) { System.out.print(dt[n]+" "); } System.out.println(); } //结束处理传入数组 cstmt.close(); con.close(); long end = System.currentTimeMillis(); System.out.println(end-start); return result;  

你可能感兴趣的:(java)