Home | Previous Page | Next Page   Appendix A. Connecting to Databases >

Using Nondefault Connection Contexts

This section explains how to use nondefault connection contexts. Embedded SQLJ uses a connection-context object to manage the connection to the database in which you want an SQL statement to execute. You can specify different connection-context objects for different SQL statements in the same Embedded SQLJ program, as shown in the sample program MultiConnect.sqlj included in this section.

To use a nondefault connection context
  1. Define the connection-context class by using an Embedded SQLJ connection statement. The syntax of the connection statement is as follows:
    #sql [modifiers] context java_class_name;
modifiers
A list of Java class modifiers: for example, public
java_class_name
The name of the Java class of the new connection context
  1. Create a connection-context object for connecting to the database.
  2. Specify the connection-context object in your Embedded SQLJ statement in parentheses following the #sql string.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]