For information about how and why to use a DataSource object, see the documentation provided by Sun Microsystems, available on the Web at http://java.sun.com.
IBM Informix JDBC Driver 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 Appendix B. 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 may 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 may 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 |
The networkProtocol and roleName properties are not supported by IBM Informix JDBC Driver.
If an LDAP (Lightweight Directory Access Protocol) server or sqlhosts file provides the IP address, host name, or port number 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.
For a list of supported environment variables (properties), see Using Informix Environment Variables. For a list of Informix DataSource extensions, which allow you to define environment variable values and connection pool tuning parameters, see Appendix B. DataSource Extensions. The driver does not consult the user's environment to determine environment variable values.
For information about the ConnectionPoolDataSource object, see Using a Connection Pool.
You can use a DataSource object with High-Availability Data Replication. For more information, see Using High-Availability Data Replication.
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()); }
The following are examples of the IFX_LOCK_MODE_WAIT connection property using a DataSource object:
IfxDataSource ds = new IfxDataSource (); ds. setIfxIFX_LOCK_MODE_WAIT (65); // wait for 65 seconds ... int waitMode = ds.getIfxIFX_LOCK_MODE_WAIT ();
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 ();Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]