|
Hi, Try this: Before you can call your AS/400 pgm using CallableStatement you have to create stored procedure (using interactive sql ) command looks something like this: CREATE PROCEDURE yourlib/yourpgm(IN p1 CHAR ( 10), IN p2 CHAR ( 15), OUT p3 DEC (7, 2)) NOT DETERMINISTIC CONTAINS SQL EXTERNAL NAME yourlib/yourpgm PARAMETER STYLE GENERAL After that you can: CallableStatement callStatement = connection.prepareCall("call yourlib.yourpgm (?, ?, ?) "); callStatement.setString(1, " parm1 "); callStatement.setString(2, " parm2 "); callStatement.registerOutParameter(3, java.sql.Types.DECIMAL); callStatement.execute(); BigDecimal r = (BigDecimal)callStatement.getBigDecimal(3); p3 is an out parm, so you can get something back from your AS/400. Alex -----Original Message----- From: P.Goovaerts@xxxxxxxxxx [mailto:P.Goovaerts@xxxxxxxxxx] Sent: Thursday, March 20, 2003 11:35 AM To: java400-l@xxxxxxxxxxxx Subject: Re: JAVA400-L Digest, Vol 1, Issue 631 Thank you all! although I got another problem now: When I execute stmt.executeUpdate("CALL MYPGM('parm1')"; where parm1="xxxxxxxxxx " it seems that the trailing spaces are left out at execution_time.... The CL/RPG program receives: "xxxxxxxxxx???????????????" where ??...?? is 'rubbish' in stead of spaces. Because the application checks if that part is blank it goes wrong. To be complete, the parameter is in fact a bit longer (first 15 chars are filled, next 350chars are a list of 10-35char fields which sometimes contain data, sometimes not! >> date: Tue, 18 Mar 2003 10:12:08 -0500 >> from: "Tim Kosacek" <tkosacek@xxxxxxxxxxxxxx> >> subject: RE: how to submit a job on iSeries from webapplication >> >> This is off the top of my head, so hopefully the syntax would be >> correct! >> >> Hopefully this formats OK, >> >> import java.sql.Connection; >> import java.sql.DriverManager; >> import java.sql.SQLException; >> import java.sql.Statement; >> >> public class TestProgramCallJDBC >> { >> >> public static void main(String[] args) >> { >> Connection con = null; >> Statement stmt = null; >> try >> { >> >> Class.forName("com.ibm.as400.access.AS400JDBCDriver"); >> con = >> DriverManager.getConnection("jdbc:as400://mysystem/mylibrary", >> "myuser", "mypassword"); >> stmt = con.createStatement(); >> stmt.executeUpdate("CALL >> MYPGM('parm1','parm2','parm3'"); >> } >> catch (Exception e) >> { >> e.printStackTrace(); >> } >> finally >> { >> if (stmt != null) >> { >> try >> { >> stmt.close(); >> } >> catch (SQLException e) >> { >> e.printStackTrace(); >> } >> } >> if (con != null) >> { >> try >> { >> con.close(); >> } >> catch (SQLException e) >> { >> e.printStackTrace(); >> } >> } >> } >> } >> } >> >> Just substitute how you get the connection, and the program you want to >> call. Hopefully this helps. >> >> Tim _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.