从 Java 读取 COBOL 数据结构

发布于 2024-07-18 09:09:46 字数 245 浏览 6 评论 0原文

有没有办法在Java程序中读取COBOL数据? 更具体地说,我面临以下情况:

我有一个包含固定长度数据记录的文件。 数据定义以 COBOL copybook 的形式完成。 我想到了一个考虑抄写本并能够阅读这些记录的图书馆。

理想情况下,应该能够根据抄写信息生成基本的 Java 类和结构。 在稍后的步骤中,将解析数据记录并将数据填充到这些生成的类的对象中。

还有其他技术可以解决读取 COBOL 数据的问题吗?

Is there a way to read COBOL data in a Java program? More concretely I'm confronted with the following case:

I have a file with fixed length records of data. The data definition is done as COBOL copybooks. I think of a library which is taking into account the copybooks and would be able to read those records.

Ideally, it should be possible to generate basic Java classes and structures based on the copybook information. In a later step the datarecords would be parsed and the data filled into objects of those generated classes.

Are there any other techniques to cope with the problem of reading COBOL data?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

东走西顾 2024-07-25 09:09:46

您可以查看 JRecordcb2java. 两者都允许您访问 COBOL 文件,但都不会生成完整的类。


2011 年 1 月更新

自从最初的答案:

  • JRecord 继续开发。 现在有一个 JRecord 代码生成器,可以作为独立程序使用,也可以在 中使用记录编辑器
    此代码生成器将从 COBOL Copybook 构建 JRecord JRecord 代码。 请参阅 RecordEditor Jrecord CodeGen
  • 开发 < strong>cb2java 已停止
  • cobol2j 已写入。 已经一年没有更新了。
  • 还有 Legstar 又几年没有发布任何内容

更新 2017 年 8 月

RecordEditor 有一个生成选项,用于从 COBOL Copybook 生成 Java / JRecord 代码。 有关详细信息,请参阅 RecordEditor 代码生成说明

2018 年 1 月更新

此问题/答案中有一些有关生成 Java~JRecord 代码的信息:

如何为 Cobol copybook 生成 java~jrecord 代码

You could look at JRecord or cb2java. Both allow you to access COBOL files, but neither will generate the full classes.


Update Jan 2011

Since the original answer:

  • JRecord continues be developed. There is now a JRecord Code generator available as either a standalone program or in the Recordeditor.
    This Code Generator will build JRecord JRecord code from a COBOL Copybook. See RecordEditor Jrecord CodeGen)
  • Development on cb2java has stopped
  • cobol2j has been written. There have been no updates for a year.
  • There is also Legstar again nothing published for a few years

Update Aug 2017

The RecordEditor has a Generate option for generating Java / JRecord code from a COBOL Copybook. See RecordEditor Code Generation notes for details.

Update Jan 2018

There is some information on generating Java~JRecord code in this question / answer:

How do you generate java~jrecord code for a Cobol copybook

不回头走下去 2024-07-25 09:09:46

是的。 我以前也这么做过。 我使用 ODBC 连接到 COBOL 文件,然后通过 jdbc:odbc 桥,使用元数据信息生成类、读取数据并将其全部移植到 Oracle。

这里是一个很好的教程如何使用 JDBC 访问元数据信息。 这里是另一个。

请记住,您不需要 JDBC:ODBC 桥接方法。 如果您可以获得本机 JDBC 驱动程序来连接到您的 Cobol 数据源,那就更好了。 对此,我也使用了IBM原生驱动。 不过不记得名字了。 很久以前了。

Yes. I have done that before. I used an ODBC connection to COBOL files, and then with jdbc:odbc bridge, I used metadata information to generate classes, read data and port it all to Oracle.

Here is a nice tutorial on how to access metada information with JDBC. Here is another one.

Keep in mind that you don't need the JDBC:ODBC bridge approach. If you can get a native JDBC driver to connect to your Cobol DataSource, it will be better. In this regard, I also used an IBM native driver. Don't remember the name though. It was a long time ago.

远昼 2024-07-25 09:09:46

似乎有一些商业解决方案为了这。 或者,您可以使用 cb2xml 将抄写本转换为 XML,然后使用您选择的任何机制将 XML 导入 Java要求。

There appear to be some commercial solutions for this. Alternatively you can use cb2xml to convert the copybooks to XML, and then import the XML into Java using whatever mechanism you require.

著墨染雨君画夕 2024-07-25 09:09:46

我在我的项目中使用了 Bruce 的 JRecord(来自 sourceforge)包。 我只花了几天时间就学会了使用它,并为我自己推出了一个不太通用的解决方案节省了几个月的时间。 我强烈推荐它。

I have used Bruce's JRecord (from sourceforge) package for my project. It took only couple of days to learn to use it and saved me months of work in rolling out a much less general solution on my own. I recommend it highly.

动次打次papapa 2024-07-25 09:09:46

Microfocus 提供了一种从 Java 调用 OO COBOL 的方法。

“您可以在 OO COBOL 中编写类,这些类可以从 Java 程序中调用,就好像它们是 Java 类一样。您可以通过提供 Java 包装类来实现这一点,该类为 OO COBOL 类中的每个方法提供一个函数。Net Express 类和方法向导通过在生成 COBOL 代码的同时生成 Java 代码,使这一切变得简单。”

他们还提供了一个名为 Enterprise Server 的工具,允许 COBOL 与 Web 服务交互。

如果您有一个 COBOL 程序 A,该工具允许您将 A 的接口部分公开为 Web 服务。

当然,因为 A 现在有一个 Web 服务,所以任何其他类型的程序(命令行、Windows 应用程序、Java、ASP 等)现在也可以调用它,从而将 COBOL 数据传递到 Java 程序。

Microfocus provide a way of calling OO COBOL from Java.

"You can write classes in OO COBOL which can be called from Java programs as though they were Java classes. You do this by providing a Java wrapper class, which provides a function for each method in the OO COBOL class. The Net Express Class and Method Wizards make this easy for you, by generating the Java code at the same time as the COBOL code."

They also provide a tool called Enterprise Server which allows COBOL to interact with web services.

If you have a COBOL program A, the tool allows you to expose A's interface section as a web service.

Of course, because A now has a web service any other type of program (command line, Windows application, Java, ASP etc.) can now also call it and hence pass the COBOL data across to a Java program.

东走西顾 2024-07-25 09:09:46

BEA 曾经有一款名为 JAM 的产品,用于与大型机 COBOL 程序进行通信。 它包括一个工具,可以读取抄写本并生成相应的 Java POD 类和数据转换代码。

我不知道这是否仍然可用,当我离开 BEA 时我就失去了它的踪迹。

BEA used to have a product named JAM that was used to communicate with mainframe COBOL programs. It included a tool that would read copybooks and generate both corresponding Java POD classes and data conversion code.

I don't know if this is still available, I lost track of it when I left BEA.

怼怹恏 2024-07-25 09:09:46

Rational Application Developer 可以读取 COBOL 源代码并生成 Java 类。 生成的类具有用于访问 COBOL 数据结构的各个部分的方法。 生成的类与 J2EE 连接器体系结构 兼容。 要在项目中创建类,请选择“文件”、“新建”、“其他”,然后选择 J2C 下的 CICS/IMS Java 数据绑定向导。 点击下一步。 选择 COBOL 到 Java 进行映射。 选择您的 COBOL 文件。 选择您希望为其生成 Java 类的结构,然后单击“完成”即可。 当然,您可以选择很多我没有提到的选项。 有关详细信息,请搜索 J2C 帮助。

Rational Application Developer can read COBOL source code and generate Java classes. The generated classes have methods for accessing the various part of the COBOL data structure. The class that is generated is compatible with the J2EE Connector Architecture. To create a class in your project, select File, New, Other then select the CICS/IMS Java Data Binding wizard under J2C. Click next. Choose COBOL to Java for mapping. Select your COBOL file. Select the structure you wish to generate a Java class for then click Finish and there you go. There are of course a number of options you can select along the way that I didn't mention. For more information search Help for J2C.

恋你朝朝暮暮 2024-07-25 09:09:46

查看 Javolution Struct

然后,您可以使用宏将 COBOL 数据转换为 Struct

Have a look at Javolution Struct.

You can then use a macro to convert your COBOL datat into Struct.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文