The ConnectionManager Class You use the ConnectionManager class to make a connection to a database, as described in "Connecting to a Database". The ConnectionManager class has two methods:
Your Embedded SQLJ program uses Informix JDBC Driver to connect to an Informix database. Informix JDBC Driver supports database URLs of the following format:
INFORMIXSERVER=
ip-address or
domain-name
Yes
The IP address or the domain name of the computer running the Informix database server.
An example of an IP address is 123.45.67.89.
123.45.67.89
An example of a domain name is myhost.com.
myhost.com
port-number
The port number of the Informix database server.
dbname
No
The name of the Informix database to which you want to connect. If you do not specify the name of a database, a connection is made to the Informix database server.
server-name
The name of the Informix server to which you want to connect. This is the value of the INFORMIXSERVER environment variable.
The INFORMIXSERVER environment variable is required in the database URL, unless it is included in the property list.
username
The name of the user you want to connect to the Informix database or database server as.
password
The password of the user specified by username.
name=value
A name-value pair that specifies a value for the Informix environment variable contained in the name variable, recognized by either Informix JDBC Driver or Informix database servers. The value of name is case insensitive.
Refer to the Informix JDBC Driver Programmer's Guide for information about environment variables supported by Informix JDBC Driver and how to set them.
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:
modifiers
A list of Java class modifiers: for example, public
java_class_name
The name of the Java class of the new connection context
2. Create a connection-context object for connecting to the database.
3. Specify the connection-context object in your Embedded SQLJ statement in parentheses following the #sql string.