Skip to main content

Exercises

Exercise 1: Add a method to JDBCExercises.java that satisfies the following requirements:

  • Has the following signature: public static void insertContact(Database db, String name, String type ) throws CacheException, SQLException

  • Inserts a new row in JavaTutorial.Contact with a Name value of name and a ContactType value of type

  • Displays a success message displaying the number of updated rows

Test the method.

Exercise 2: Add a method to JDBCExercises.java that satisfies the following requirements:

  • Has the following signature: public static void displayPhoneNumbersByTypeAndName(Database db, String name, String type) throws CacheException, SQLException

  • Displays all of the Number values for the JavaTutorial.PhoneNumber rows with PhoneNumberType value type and where the value of Name for the associated JavaTutorial.Contact row is name

  • Uses the Caché implicit join syntax

Test the method.

Exercise 3: Add a method to JDBCExercises.java that satisfies the following requirements:

  • Has the signature: public static void displayPhoneNumberIdsByName(Database db, String name) throws CacheException, SQLException

  • Displays all of the ID values for the JavaTutorial.PhoneNumber rows associated with the JavaTutorial.Contact row with Name value name

  • Uses the stored procedure RetrieveByContactName stored with JavaTutorial.PhoneNumber

Test the method.

Note:

In general, the connection string for connecting to Caché has the following form: jdbc:Cache://<server>:<port>/<namespace>, where <server> is the IP address of the server hosting Caché, port is the SuperServer port number for your Caché instance, and namespace is the Caché namespace containing your Caché classes and data. Click the About link on the upper left-hand corner of the Management Portal to determine the SuperServer port number for your Caché instance. The default is 1972.

FeedbackOpens in a new tab