Java 调用存储过程中的集合,如何传参

public String updatefileInfo(String fileId, ArrayList list) {
		Object[] tmp = new Object[list.size()];
		for (int i = 0; i < tmp.length; i++) {
			Object[] tmparc = new Object[5];
			ASObject aso = (ASObject) list.get(i);

			//与type的类型,字段名称相同
			int FILE_ID = Integer.parseInt((String) aso.get("fileid"));// 文件编号
			String FILE_NAME = (String) aso.get("filename");// 文件名称
			String USERID = (String) aso.get("userId");// 上传人编号
			String FILE_TYPE = (String) aso.get("filetype");// 文件类型
			String FILE_SIZE = (String) aso.get("filesize");// 文件大小

			tmparc[0] = FILE_ID;
			tmparc[1] = FILE_NAME;
			tmparc[2] = USERID;
			tmparc[3] = FILE_TYPE;
			tmparc[4] = FILE_SIZE;
			tmp[i] = tmparc;
		}
		String state = updateInfo(fileId, tmp);
		return state;
	}

	public String updateInfo(String fileId, Object[] obj) {
		Connection conn = DbManager.getConnection();
		CallableStatement stmt = null;
		ResultSet rs = null;
		String state = "";
		try {
			ArrayDescriptor arrayDept = ArrayDescriptor.createDescriptor(
					"TP_FILELIST", conn);// type  参数类型
			STRUCT[] laneArray = new STRUCT[obj.length];
			ARRAY arrayObject = null;
			StructDescriptor st = new StructDescriptor("OBJ_FILELIST", conn);//具体参数
			for (int i = 0; i < obj.length; i++) {
				STRUCT st2 = new STRUCT(st, conn, (Object[]) obj[i]);
				laneArray[i] = st2;
			}
			arrayObject = new ARRAY(arrayDept, conn, laneArray);
			stmt = conn
					.prepareCall("{call PKG_QUALITY.UPDATE_FILEANNEX(?,?,?)}");
			stmt.setString(1, fileId);
			stmt.setArray(2, arrayObject);
			stmt.registerOutParameter(3, OracleTypes.VARCHAR);
			stmt.execute();
			state = stmt.getString(3);
		} catch (Exception e) {
			System.out.println(e.toString());

		} finally {
			try {
				DbManager.closeAll(rs, stmt, conn);
			} catch (Exception e) {
				System.out.println(e.toString());
			}
		}
		return state;
	}

你可能感兴趣的:(java,技术)