Returning Result Sets from JDBC

A sample JDBC application is called from the database server to return multiple result sets.

Prerequisites

A Java Development Kit (JDK) must be installed.

Task
  1. Connect to the database from Interactive SQL.
  2. Ensure the JDBCExample class has been installed.
  3. Define a stored procedure named JDBCResults that acts as a wrapper for the JDBCExample.Results method in the class.

    For example:

    CREATE PROCEDURE JDBCResults(OUT args LONG VARCHAR)
      DYNAMIC RESULT SETS 3
      EXTERNAL NAME 'JDBCExample.Results([Ljava/sql/ResultSet;)V'
      LANGUAGE JAVA;

    The example returns 3 result sets.

  4. Set the following Interactive SQL options so you can see all the results of the query:
    1. Click Tools » Options.

    2. Click Sybase IQ.

    3. Click the Results tab.

    4. Set the value for Maximum Number Of Rows To Display to 5000.

    5. Click Show All Result Sets.

    6. Click OK.

  5. Call the JDBCExample.Results method.
    CALL JDBCResults();
  6. Check each of the three results tabs, Result Set 1, Result Set 2, and Result Set 3.

Three different result sets are returned from a server-side JDBC application.