Dear all, My ADD_REC stored procedure takes 2 varchar2 in parameters. The following call raises exception. ... CallableStatement storedProc = con.prepareCall("{call ADD_REC(?,?)}"); storedProc.setString(1,"AAAA"); storedProc.setString(2,"BBBB"); storedProc.executeUpdate(); ... But if I make ADD_REC stored procedure parameterless the following call works fine. ... CallableStatement storedProc = con.prepareCall("{call ADD_REC}"); storedProc.executeUpdate(); ... Can't we call PL/SQL stored procedures with parameters from within Java? Help please. Thanks Ambrose Tati
Monty Ireland
Ranch Hand
Joined: Oct 03, 2000
Posts: 161
posted
0
I have not tested this feature. But, it should work.. Enclosed you will find an application that exec a db2 stored procedure. For what it is worth... I hope it helps. <code> import java.sql.*;// java sql classes public class JdbcTest { public static void main(String args[]) { try { String userid, password; String account, subgroup, segment, category, sector, level4; String fromdate, todate, annind, incretind, rtntyp; System.out.println("Loading JDBC Driver ..." ); Class.forName("COM.ibm.db2.jdbc.app.DB2Driver"); System.out.println("Connecting To jdbc:db2SNT ..." ); userid = "USER_ID"; password = "PASSWORD"; Connection con = DriverManager.getConnection("jdbc:db2SNT", userid, password ); System.out.println("Creating SQL Statement ..." ); String sqlsp = "call SPPEF001 ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";