DB2 10.5 for Linux, UNIX, and Windows

DB2DataSource class

The com.ibm.db2.jcc.DB2DataSource class extends the DB2BaseDataSource class, and implements the javax.sql.DataSource, java.io.Serializable, and javax.naming.Referenceable interfaces.

DB2DataSource methods

The following methods are defined only for the IBM® Data Server Driver for JDBC and SQLJ.

setSpecialRegisters
Format:
public void setSpecialRegisters(java.util.Properties properties)
  throws java.sql.SQLException

For each key and value pair in the java.util.Properties object, sets the data server special register that is specified by the key to the corresponding value.

This method does not apply to connections to IBM Informix® data servers.

Parameter description:

properties
A java.util.Properties object that contains key and value pairs, in which each key is the name of a special register, and each value is the value to which you want to set that special register. For example, suppose that ds is a previously defined DataSource object. Set the property values in the following way.
Properties prop = new Properties();
prop.put ("CURRENT SCHEMA", "SYSPROC");
prop.put ("CURRENT PACKAGESET", "PRODUCTION");
((com.ibm.db2.jcc.DB2BaseDataSource) ds).setSpecialRegisters(prop);

Certain special registers can be set through IBM Data Server Driver for JDBC and SQLJ properties. If you set a special register value by setting one of those properties in a java.util.Properties object, and then use setSpecialRegisters to set a value for the same special register, the value that is set through setSpecialRegisters overrides the value that is set through the property. In the following example, CURRENT SCHEMA is set to USER002:

Properties prop = new Properties();
((com.ibm.db2.jcc.DB2BaseDataSource) ds).setCurrentSchema("USER001");
properties. put ("CURRENT SCHEMA", "USER002");
((com.ibm.db2.jcc.DB2BaseDataSource) ds).setSpecialRegisters(prop);

For a complete description of the rules for using setSpecialRegisters to set special registers on DB2® for z/OS® data servers, see General rules for special registers (DB2 SQL).

setGlobalSessionVariables
Format:
public void setGlobalSessionVariables(java.util.Properties properties)
  throws java.sql.SQLException

For each key and value pair in the java.util.Properties object, sets the session variable that is specified by the key to the corresponding value.

This method applies only to connections to DB2 for z/OS Version 11 or later data servers.

Parameter description:

properties
A java.util.Properties object that contains key and value pairs, in which each key is the name of a session variable, and each value is the value to which you want to set that session variable. For example, suppose that ds is a previously defined DataSource object. Set the property values in the following way.
Properties prop = new Properties();
prop.put ("SESSION.TEST", "TEST FAILED");
prop.put ("SYSIBMADM.GET_ARCHIVE", "Y");
((com.ibm.db2.jcc.DB2BaseDataSource) ds).setGlobalSessionVariables(prop);