Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling RPG as part of a java/jdbc transaction

309 views
Skip to first unread message

Sepp Muegeli

unread,
May 7, 2001, 12:57:26 PM5/7/01
to
Hi all,

I have to call a RPG-programm from Java on the AS/400. There are many
ways to do this, I use stored procedures for now.

The problem is, that the RPG-programm should act as a part of a
transaction. That means, do some update via jdbc, call the RPG, do some
more updates via jdbc. Then do a commit or rollback that should
commit/rollback all the updates from jdbc AND from the RPG-programm.

Is there a possible way to do this?

Thanks for any answers.
Sepp

Ugo Gagliardelli

unread,
May 7, 2001, 2:18:52 PM5/7/01
to
Sepp Muegeli wrote:
>
> Hi all,
>
> I have to call a RPG-programm from Java on the AS/400. There are many
> ways to do this, I use stored procedures for now.
>
> The problem is, that the RPG-programm should act as a part of a
> transaction. That means, do some update via jdbc, call the RPG, do some
> more updates via jdbc. Then do a commit or rollback that should
> commit/rollback all the updates from jdbc AND from the RPG-programm.
You can do it via java toolbox or via JNI. AS/400 JNI only support the
"link" of a service program, just as it were a .dll in an OS/2 or Win
environment.
Be aware that commit/rollback is not fully thread-safe, that is, in any
multythreaded environment, a commit/rollback will perform for all the
thread of the same group. So if you have, let's say, thread-A in the
middle of a transaction and thread-B does a commit, the transaction of
thread-A will be committed too.
Refer to "Information Center AS/400 ", "Programming" section
"Multithreaded Application" sub-section at
http://publib.boulder.ibm.com/html/as400 for more information

--
Dr. Ugo Gagliardelli, Modena, Italy
Spaccamaroni andate a cagare/Spammers not welcome

Ugo Gagliardelli

unread,
May 7, 2001, 2:32:38 PM5/7/01
to
Ugo Gagliardelli wrote:
...too fast click...

Refer to "Information Center AS/400 ", "Java" link "AS/400 Developer Kit
for Java " section "Other programming languages" sub-section at
http://publib.boulder.ibm.com/html/as400 for more information about JNI
on AS/400.

Fred A. Kulack

unread,
May 7, 2001, 3:34:14 PM5/7/01
to
In ILE C, I'd tell you simply to make your RPG program
*CALLERs activation group and ensure that it doesn't
do any commitment control functions.
Then, when called as the stored procedure, your
committable work would be under control
of the JDBC connection that it was called from.
In RPG... The same way?

--
"The stuff we call "software" is not like anything that human society
is used to thinking about. Software is something like a machine, and
something like mathematics, and something like language, and
something like thought, and art, and information...
but software is not in fact any of those other things."
Bruce Sterling - The Hacker Crackdown

Fred A. Kulack - AS/400e Java and Java DB2 access, Jdbc, JTA, etc...
IBM in Rochester, MN (Phone: 507.253.5982 T/L 553-5982)
mailto:kul...@us.ibm.com Personal: mailto:kul...@bresnanlink.net
AOL Instant Messenger Home:FKulack Work:FKulackWrk


MBO

unread,
May 8, 2001, 4:54:41 PM5/8/01
to
6 months ago we tried to do that and we obtained bad results. We tried
differently setup of the JDBC driver but when RPG pgm ended, the
transaction were committed ! We don't have the good solution. Sorry.

Sepp Muegeli a écrit :

Sepp Muegeli

unread,
May 9, 2001, 4:30:45 AM5/9/01
to
MBO schrieb:

>
> 6 months ago we tried to do that and we obtained bad results. We tried
> differently setup of the JDBC driver but when RPG pgm ended, the
> transaction were committed ! We don't have the good solution. Sorry.
>
> Sepp Muegeli a écrit :
>
> > I have to call a RPG-programm from Java on the AS/400. There are many
> > ways to do this, I use stored procedures for now.
> >
> > The problem is, that the RPG-programm should act as a part of a
> > transaction. That means, do some update via jdbc, call the RPG, do some
> > more updates via jdbc. Then do a commit or rollback that should
> > commit/rollback all the updates from jdbc AND from the RPG-programm.


Thanks for the answer. That shows at least that I'm not the only one
trying to do such funny things ;-)
Did you also try other ways to call the RPG-program (JNI, Toolbox, call
as service-pgm)? I would prefer the stored procedure way because it is
platform independent, but if there is an other solution to the problem I
would be happy too.

Sepp

Ugo Gagliardelli

unread,
May 9, 2001, 6:54:12 AM5/9/01
to
Sepp Muegeli wrote:
> Thanks for the answer. That shows at least that I'm not the only one
> trying to do such funny things ;-)
> Did you also try other ways to call the RPG-program (JNI, Toolbox, call
> as service-pgm)?
Shout its name!
:))

Joel Eikenhorst

unread,
May 9, 2001, 12:02:19 PM5/9/01
to
1) Make your RPG program run it in the callers activation group by using
*CALLER.
2) Set AutoCommit off for your JDBC connection.
3) Set the transaction isolation level to something other than None for
your JDBC connection.

This should Commit or rollback all changes made in the database by either
stored procedures or JDBC SQL statements. Since all changes are made in
the same JOB and activation group (the server job, QZDASOINIT or QSQSRVR),
the RPG program doesn't end, and there is no autocommit happening your JDBC
connection will be in charge of commiting and rolling back.

Michel Bonnetaud

unread,
May 16, 2001, 10:52:28 AM5/16/01
to
Hi,
You can call RPG Program with using stored procedure. There are two cases :

RPG "classic" and SQLRPG.
On the client, you can leave default options of the JDBC Driver.
DriverManager.registerDriver(new AS400JDBCDriver());
Connection c =
DriverManager.getConnection("jdbc:as400://MySystem;libraries=MYLIB1,MYLIB2",
"USER", "PASSWORD");
CallableStatement cs = c.prepareCall("CALL MYLIB.MYPROC");
c.setAutoCommit(false);
cs.execute();
cs.execute();
//c.rollback(); (just to test)
c.commit();

On the server, in case of SQLRPG, no particularity
in case of RPG, you must specify KeyWord "COMMIT" on file specification
(each file under commitment control).


0 new messages