Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » JDBC support » Data access using JDBC

 

Returning result sets from JDBC

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

Prérequis

A Java Development Kit (JDK) must be installed.

To create an external procedure, you must have the CREATE PROCEDURE and CREATE EXTERNAL REFERENCE system privileges. You must also have SELECT, DELETE, and INSERT privileges on the database object you are modifying.

 Task
  1. Connect to the database from Interactive SQL.

  2. Ensure the JDBCExample class has been installed.

    For more information about installing the Java examples classes, see Preparing for the JDBC examples.

  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 SQL Anywhere.

    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.

Résultat

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