0

I am trying to call an RPG program from Java. I can get the program to run correctly using the DriverManager as follows:

Connection conn = DriverManager.getConnection("jdbc:as400://" + "sys" + "", "username", "pass");
Statement stmt = conn.createStatement();
Boolean sqlBool = stmt.execute("call DB2.PROGRAM");

However...this is not the way that I want to do it. I want to use the JNDI to connect to the 400 and run the program call, as that is the way I do it to run SELECT, UPDATES, DELETES, etc...

Here is the pseudocode that I have so far, and I am having the RPG fail on the SaveObject.

Context context = new InitialContext();
DataSource ds = (DataSource) context.lookup(JNDI_NAME);
Connection conn = datasource.getConnection();
Statement stmt = conn.createStatement();
Boolean sqlBool = stmt.execute("call DB2.PROGRAM");

Is this a problem with the JNDI connection or a problem with the RPG?

Update: It appears that when the SaveObject job goes to work, it says that the table is locked. I am doing inserts and deletes against this table before running the RPG call...any ideas? What would cause a table to still be locked even if I am closing all connections to the database after processing.

4

2 回答 2

1

DB2 可以将表保持部分打开一段时间,因为它不知道何时再次需要它。下一秒可能会出现另一个 UPDATE,而 DB2 希望避免对每个事务都完全打开。只要这种情况继续存在,您就可以找到锁争用。

如果您遇到这样的锁,请先尝试您的 RPG 程序中的 ALCOBJ CONFLICT(*RQSRLS),然后查看您的SaveObject进程是否完成。有关何时有用的说明,请参阅该参数的 ALCOBJ 帮助文本。

于 2014-10-01T00:01:01.193 回答
0

好的,所以我昨天和今天的大部分时间都在浏览代码,最后弄清楚发生了什么。

在 Websphere 中,JDBC 自定义属性中有一个名为:trueAutoCommit 的变量。此变量默认设置为 FALSE。

我将其更改为 true,它允许事务在运行时单独完成,现在我使用单独的“事务”调用 RPG 程序,它不会锁定表。

于 2014-10-01T19:33:49.380 回答