A DataSource object

extends the standard DataSource interface to allow connection properties (both the standard properties and Informix® environment variables) to be defined in a DataSource object instead of through the URL.

The following table describes how Informix connection properties correspond to DataSource properties.
Informix connection property DataSource property Data type Required? Description
IFXHOST None; see DataSource extensions for how to set IFXHOST. String Yes for client-side JDBC, unless SQLH_TYPE is defined; no for server-side JDBC The IP address or the host name of the computer running the Informix database server
PORTNO portNumber int Yes for client-side JDBC, unless SQLH_TYPE is defined; no for server-side JDBC The port number of the Informix database server. The port number is listed in the /etc/services file.
DATABASE databaseName String No, except for connections from web applications (such as a browser) running in the database server 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.

INFORMIXSERVER serverName String Yes for client-side JDBC; ignored for server-side JDBC The name of the Informix database server to which you want to connect
USER user String Yes The user name controls (or determines) the session privileges when connected to the Informix database or database server

Normally, you must specify both user name and password; however, if the user running the JDBC application is trusted by the DBMS, you might omit both.

PASSWORD password String Yes The password of the user

Normally, you must specify both the user name and the password; however, if the user running the JDBC application is trusted by the DBMS, you might omit both.

None description String Yes A description of the DataSource object
None dataSourceName String No The name of an underlying ConnectionPoolDataSource or XADataSource object for connection pooling or distributed transactions

Unsupported connection properties

The networkProtocol and roleName properties are not supported by .

Specify connection information

If an LDAP (Lightweight Directory Access Protocol) server or sqlhosts file provides the IP address, host name, or port number or service name of the Informix database server through the SQLH_TYPE property, you do not have to specify them using the standard DataSource properties. For more information, see Dynamically reading the Informix sqlhosts file.

ConnectionPoolDataSource object

For information about the ConnectionPoolDataSource object, see A connection pool.

Environment variables

For a list of supported environment variables (properties), see Informix environment variables with the. For a list of Informix DataSource extensions, which allow you to define environment variable values and connection pool tuning parameters, see DataSource extensions. The driver does not consult the users environment to determine environment variable values.

High-availability data replication

You can use a DataSource object with High-Availability Data Replication. For more information, see Connections to the servers of a high-availability cluster.

Example: Use of a DataSource object in an example program

The following code from the pickaseat example program defines and uses a DataSource object:
IfxConnectionPoolDataSource cpds = null;
try
{
   Context initCtx = new InitialContext();
   cpds = new IfxConnectionPoolDataSource();
   cpds.setDescription("Pick-A-Seat Connection pool");
   cpds.setIfxIFXHOST("158.58.60.88");
   cpds.setPortNumber(179);
   cpds.setUser("demo");
   cpds.setPassword("demo");
   cpds.setServerName("ipickdemo_tcp");
   cpds.setDatabaseName("ipickaseat");
   cpds.setIfxGL_DATE("%B %d, %Y");
   initCtx.bind("jdbc/pooling/PickASeat", cpds);
}
catch (Exception e)
{
   System.out.println("Problem with registering the CPDS");
   System.out.println("Error: " + e.toString());
}

Example: Use of a DataSource object with the IFX_LOCK_MODE_WAIT connection property

The following are examples of the IFX_LOCK_MODE_WAIT connection property that use a DataSource object:

Example 1
IfxDataSource ds = new IfxDataSource ();
ds. setIfxIFX_LOCK_MODE_WAIT (65);    // wait for 65 seconds
…
int waitMode = ds.getIfxIFX_LOCK_MODE_WAIT ();
Example 2
An example Using DataSource:
IfxDataSource ds = new IfxDataSource ();
ds.setIfxIFX_ISOLATION_LEVEL ("0U");    // set isolation to dirty read with
             retain 
     //  update locks.
….
String isoLevel = ds.getIfxIFX_ISOLATION_LEVEL ();

Copyright© 2020 HCL Technologies Limited