CallableStatement cstmt = conn.prepareCall("{call myStoredProcedure(?,?)}"); cstmt.setString(1, "John"); cstmt.setObject(2, new BigDecimal("12000.5")); cstmt.execute();
CallableStatement cstmt = conn.prepareCall("{call myStoredProcedure(?,?,?,?)}"); cstmt.setInt(1, 101); cstmt.setObject(2, new java.util.Date()); cstmt.setString(3, "John"); cstmt.setString(4, "Doe"); cstmt.execute();In this example, we are passing four input parameters to the stored procedure "myStoredProcedure". The first parameter is an integer, the second parameter is a date, and the last two parameters are strings. We are passing the date value using the setObject method as it is not known in advance. The CallableStatement interface is part of the java.sql package library.