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
--
Dr. Ugo Gagliardelli, Modena, Italy
Spaccamaroni andate a cagare/Spammers not welcome
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.
--
"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
Sepp Muegeli a écrit :
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
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.
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).