Using a Java Method with Arguments

  • The two arguments are the department id (an integer) and the department name (a string). Here, both arguments pass to the method as strings, because they are part of the SQL statement string.

  • The INSERT is a static statement and takes no parameters other than the SQL itself.

  • If you supply the wrong number or type of arguments, you receive the Procedure Not Found error.

  1. If you have not already installed the JDBCExamples.class file into the demo database, do so.
  2. Connect to the demo database from Interactive SQL, and enter the following command:
    call JDBCExamples>>InsertArguments( '203', 'Northern Sales' )
  3. Verify that an additional row has been added to the Department table:
    SELECT *
    FROM Department
  4. Roll back the changes to leave the database unchanged:
    ROLLBACK