Page 1
DB2 Version 9.1 for z/OS Application Programming Guide and Reference ™ for Java SC18-9842-03...
Page 3
DB2 Version 9.1 for z/OS Application Programming Guide and Reference ™ for Java SC18-9842-03...
Page 4
Fourth edition (December 2008) This edition applies to DB2 Version 9.1 for z/OS (DB2 V9.1 for z/OS), product number 5635-DB2, and to any subsequent releases until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product.
. xi Chapter 1. Java application development for DB2 ....1 Chapter 2. Supported drivers for JDBC and SQLJ....3 JDBC driver and database version compatibility DB2 Database for Linux, UNIX, and Windows and IBM Data Server Driver for JDBC and SQLJ levels .
Page 6
IBM Data Server Driver for JDBC and SQLJ support for client affinities for cascaded failover . . 95 Failover support with IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS . . 97 Memory use for IBM Data Server Driver for IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS.
Page 7
Common IBM Data Server Driver for JDBC and SQLJ properties for DB2 for z/OS and IDS . . 224 Common IBM Data Server Driver for JDBC and SQLJ properties for IDS and DB2 Database for Linux, UNIX, and Windows .
Page 8
. 412 Chapter 8. Installing the IBM Data Server Driver for JDBC and SQLJ ..413 Installing the IBM Data Server Driver for JDBC and SQLJ as part of a DB2 installation .
Page 9
How to obtain DB2 information......503 How to use the DB2 library ......507 Notices .
Page 10
viii ™ Application Programming Guide and Reference for Java...
The DB2 Utilities Suite is designed to work with the DFSORT program, which you are licensed to use in support of the DB2 utilities even if you do not otherwise license DFSORT for general use. If your primary sort product is not DFSORT,...
Keyboard navigation You can access DB2 Version 9.1 for z/OS ISPF panel functions by using a keyboard or keyboard shortcut keys. For information about navigating the DB2 Version 9.1 for z/OS ISPF panels using TSO/E or ISPF, refer to the z/OS TSO/E Primer, the z/OS TSO/E User’s Guide, and...
If you are commenting on specific text, please list the location of the text (for example, a chapter and section title or a help topic title). v You can send comments from the Web. Visit the DB2 for z/OS - Technical Resources Web site at: http://www.ibm.com/support/docview.wss?&uid=swg27011656...
Page 14
optional_item required_item v If you can choose from two or more items, they appear vertically, in a stack. If you must choose one of the items, one item of the stack appears on the main path. required_item required_choice1 required_choice2 If choosing one of the items is optional, the entire stack appears below the main path.
Page 15
v With the exception of XPath keywords, keywords appear in uppercase (for example, FROM). Keywords must be spelled exactly as shown. XPath keywords are defined as lowercase names, and must be spelled exactly as shown. Variables appear in all lowercase letters (for example, column-name). They represent user-supplied names or values.
Page 16
™ Application Programming Guide and Reference for Java...
JDBC is an application programming interface (API) that Java applications use to access relational databases. DB2 support for JDBC lets you write Java applications that access local DB2 data or remote relational data on a server that supports ® DRDA SQLJ provides support for embedded static SQL in Java applications.
Page 18
™ Application Programming Guide and Reference for Java...
IBM Data Server Driver for JDBC and SQLJ type 2 connectivity. IBM Data Server Driver for JDBC and SQLJ type 4 driver behavior is referred to as IBM Data Server Driver for JDBC and SQLJ type 4 connectivity.
JDBC and SQLJ type 4 connectivity for Java programs that run on a different z/OS system or LPAR from the target DB2 subsystem. For z/OS systems or LPARs that do not have DB2 for z/OS, the z/OS Application Connectivity to DB2 for z/OS optional feature can be installed to provide IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to a DB2 Database for Linux, UNIX, and Windows database.
IBM Data Server Driver for JDBC and SQLJ version 2.x, which is shipped with DB2 for z/OS Version 8, to a DB2 for z/OS Version 9.1 database is supported, if the applications under which the driver runs contain no DB2 for z/OS Version 9.1 features.
Page 22
Version 9.1 Fix Pack 3 3.4.xx Version 9.5 3.5x.xx , 4.0.xx Note: 1. xx is different for each new version of the IBM Data Server Driver for JDBC and SQLJ that is introduced through an APAR. ™ Application Programming Guide and Reference for Java...
In general, you need to do the following things: v Access the Java packages that contain JDBC methods. v Declare variables for sending data to or retrieving data from DB2 tables. v Connect to a data source. v Execute SQL statements.
Page 24
// Load the driver Class.forName("com.ibm.db2.jcc.DB2Driver"); System.out.println("**** Loaded the JDBC driver"); // Create the connection using the IBM Data Server Driver for JDBC and SQLJ con = DriverManager.getConnection (url); // Commit changes manually con.setAutoCommit(false); System.out.println("**** Created a JDBC connection to the data source");...
Before you can execute SQL statements in any SQL program, you must be connected to a data source. The IBM Data Server Driver for JDBC and SQLJ supports type 2 and type 4 connectivity. Connections to DB2 databases can use type 2 or type 4 connectivity.
Page 26
*Java byte code executed under JVM, and native code Figure 2. Java application flow for IBM Data Server Driver for JDBC and SQLJ type 2 connectivity The following figure shows how a Java application connects to a data source using IBM Data Server Driver for JDBC and SQLJ type 4 connectivity.
1. Load the JDBC driver by invoking the Class.forName method. If you are using JDBC 4.0, you do not need to explicitly load the JDBC driver. For the IBM Data Server Driver for JDBC and SQLJ, you load the driver by invoking the Class.forName method with the following argument: com.ibm.db2.jcc.DB2Driver...
Page 28
Connection con = DriverManager.getConnection(url, properties); // Create connection Related concepts “How to determine which type of IBM Data Server Driver for JDBC and SQLJ connectivity to use” on page 17 “User ID and password security under the IBM Data Server Driver for JDBC and SQLJ”...
Page 29
A name for the data source. v If the connection is to a DB2 for z/OS server, database is the DB2 location name that is defined during installation. All characters in the DB2 location name must be uppercase characters. The IBM Data Server Driver for JDBC...
Page 30
The meanings of the initial portion of the URL are: jdbc:db2: or jdbc:db2os390: or jdbc:db2os390sqlj: Indicates that the connection is to a DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows server. jdbc:db2os390: and ™ Application Programming Guide and Reference for Java...
All characters in the DB2 location name must be uppercase characters. However, when the connection is to a DB2 for z/OS server, the IBM Data Server Driver for JDBC and SQLJ converts lowercase characters in the database value to uppercase.
Page 32
To learn more about using WebSphere to deploy DataSource objects, go to this URL on the Web: http://www.ibm.com/software/webservers/appserv/ To learn about deploying DataSource objects yourself, see ″Creating and deploying DataSource objects″.
453 “IBM Data Server Driver for JDBC and SQLJ trusted context support” on page “IBM Data Server Driver for JDBC and SQLJ support for SSL” on page 458 Related tasks “Connecting to a data source using SQLJ” on page 103 “Creating and deploying DataSource objects”...
Page 34
The following table summarizes the differences between type 2 connectivity and type 4 connectivity: Table 2. Comparison of IBM Data Server Driver for JDBC and SQLJ type 2 connectivity and IBM Data Server Driver for JDBC and SQLJ type 4 connectivity...
“Setting the isolation level for an SQLJ transaction” on page 153 Related reference “ IBM Data Server Driver for JDBC and SQLJ isolation levels” on page 73 Creating and deploying DataSource objects JDBC versions starting with version 2.0 provide the DataSource interface for connecting to a data source.
Page 36
453 “IBM Data Server Driver for JDBC and SQLJ trusted context support” on page “IBM Data Server Driver for JDBC and SQLJ support for SSL” on page 458 Related tasks “Connecting to a data source using the DataSource interface” on page 15 ™...
Related reference “Properties for the IBM Data Server Driver for JDBC and SQLJ” on page 201 “DB2SimpleDataSource class” on page 352 “DB2XADataSource class” on page 366 Java packages for JDBC support Before you can invoke JDBC methods, you need to be able to access all or parts of various Java packages that contain those methods.
“JDBC connection objects” on page 19 Related reference “Driver support for JDBC APIs” on page 252 “JDBC differences between the current IBM Data Server Driver for JDBC and SQLJ and earlier DB2 JDBC drivers” on page 370 DatabaseMetaData methods for identifying the type of data source You can use the DatabaseMetaData.getDatabaseProductName and...
String empNo = rs.getString(1); System.out.println("Employee number = " + empNo); Your choice of Java data types can affect performance because DB2 picks better access paths when the data types of your Java variables map closely to the DB2 data types. Related concepts “Example of a simple JDBC application”...
The CallableStatement interface can be used to call stored procedures with input parameters, output parameters, or input and output parameters, or no parameters. With the IBM Data Server Driver for JDBC and SQLJ, you can also use the Statement interface to call stored procedures, but those stored procedures must have no parameters.
Execute INSERT, UPDATE, DELETE, and MERGE statements that do not contain parameter markers. v With the IBM Data Server Driver for JDBC and SQLJ, execute the CALL statement to call stored procedures that have no parameters and that return no result sets.
Page 42
DB2 for z/OS does not support dynamic execution of the CALL statement. For calls to stored procedures that are on DB2 for z/OS data sources, the parameters can be parameter markers or literals, but not expressions. The following types of...
JDBC executeUpdate methods against a DB2 for z/OS server The JDBC standard states that the executeUpdate method returns a row count or 0. However, if the executeUpdate method is executed against a DB2 for z/OS server, it can return a value of -1.
– A positive number, if a positive number of rows are affected by the operation, and the operation is not a mass delete on a segmented table space. – 0, if no rows are affected by the operation. – -1, if the operation is a mass delete on a segmented table space. v For an SQL CALL statement, a value of -1 is returned, because the data source cannot determine the number of affected rows.
Page 45
If AutoCommit is disabled for the Connection object, invoke the commit method to commit the changes. If AutoCommit is enabled for the Connection object, the IBM Data Server Driver for JDBC and SQLJ adds a commit method at the end of the batch.
Page 46
“Making batch queries in JDBC applications” on page 34 “Committing or rolling back JDBC transactions” on page 74 Related reference “JDBC differences between the current IBM Data Server Driver for JDBC and SQLJ and earlier DB2 JDBC drivers” on page 370 ™...
Learning about parameters in a PreparedStatement using ParameterMetaData methods The IBM Data Server Driver for JDBC and SQLJ includes support for the ParameterMetaData interface. The ParameterMetaData interface contains methods that retrieve information about the parameter markers in a PreparedStatement object.
This topic discusses the simplest kind of ResultSet, which is a read-only ResultSet in which you can only move forward, one row at a time. The IBM Data Server Driver for JDBC and SQLJ also supports updatable and scrollable ResultSets.
Page 49
ResultSet methods to move through the result table and obtain the individual column values from each row. With the IBM Data Server Driver for JDBC and SQLJ, you can also use the PreparedStatement.executeQuery method to retrieve a result set from a stored procedure call, if that stored procedure returns only one result set and has only input parameters.
Page 50
“Driver support for JDBC APIs” on page 252 Making batch queries in JDBC applications The IBM Data Server Driver for JDBC and SQLJ provides a IBM Data Server Driver for JDBC and SQLJ-only DB2PreparedStatement interface that lets you perform batch queries on a homogeneous batch.
Page 51
// Add some more values to the batch pstmt.setInt(1,2); pstmt.addBatch(); pstmt.setInt(1,3); pstmt.addBatch(); pstmt.setInt(1,4); pstmt.addBatch(); ((com.ibm.db2.jcc.DB2PreparedStatement)prepStmt).executeDB2QueryBatch(); } catch(BatchUpdateException b) { // process BatchUpdateException while(pstmt.getMoreResults()) { java.sql.ResultSet rs = pstmt.getResultSet(); while (rs.next()) { System.out.print (rs.getInt (1) + " "); System.out.println (rs.getString (2));...
Page 52
The results of ResultSetMetaData.getColumnName call reflects the column name information that is stored in the DB2 catalog for that data source. The following code demonstrates how to determine the data types of all the columns in the employee table. The numbers to the right of selected statements correspond to the previously-described steps.
Page 53
Characteristics of a JDBC ResultSet under the IBM Data Server Driver for JDBC and SQLJ The IBM Data Server Driver for JDBC and SQLJ provides support for scrollable, updatable, and holdable cursors. In addition to moving forward, one row at a time, through a ResultSet, you might...
Page 54
If you delete a row of a result table, a delete hole occurs. You cannot update or delete a delete hole. Related concepts ″Temporary table space storage requirements″ (DB2 Installation Guide) Related tasks “Specifying updatability, scrollability, and holdability for ResultSets in JDBC applications”...
Page 55
TYPE_SCROLL_SENSITIVE CONCUR_UPDATABLE Note: 1. This value does not apply to connections to IBM Informix Dynamic Server. resultSetHoldability has two possible values: HOLD_CURSORS_OVER_COMMIT and CLOSE_CURSORS_AT_COMMIT. Either of these values can be specified with any valid combination of resultSetConcurrency and resultSetHoldability. The value that you set overrides the default holdability for the connection.
Page 56
Method Positions the cursor Notes: 1. This method does not apply to connections to IBM Informix Dynamic Server. 2. If the cursor is before the first row of the ResultSet, this method positions the cursor on the first row. 3. If the cursor is after the last row of the ResultSet, this method positions the cursor on the last row.
Page 57
Multi-row FETCH Multi-row FETCH can provide better performance than retrieving one row with each FETCH statement. For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS, multi-row FETCH can be used for forward-only cursors and scrollable cursors. For other types of connectivity, multi-row FETCH can be used only for scrollable cursors.
Page 58
Whether progressive streaming is being used to fetch the rows For IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows, and IBM Data Server...
Page 59
Testing whether the current row of a ResultSet is a delete or update hole in a JDBC application: If a ResultSet has the TYPE_SCROLL_SENSITIVE attribute, and the underlying cursor is SENSITIVE STATIC, you need to test for delete or update holes before you attempt to retrieve rows of the ResultSet.
Page 60
1. Perform the following steps for each row that you want to insert. a. Call the ResultSet.moveToInsertRow method to create the row that you want to insert. The row is created in a buffer outside the ResultSet. If an insert buffer already exists, all old values are cleared from the buffer. b.
CALL statement. For a call to a stored procedure that is on a DB2 for z/OS database server, the parameters can be parameter markers or literals, but not expressions. The following table lists the types of literals that are supported, and the JDBC types to which they map.
Page 62
Related reference “Driver support for JDBC APIs” on page 252 “JDBC differences between the current IBM Data Server Driver for JDBC and SQLJ and earlier DB2 JDBC drivers” on page 370 Retrieving multiple result sets from a stored procedure in a...
Page 63
“Learning about a ResultSet using ResultSetMetaData methods” on page 35 “Retrieving data from tables using the PreparedStatement.executeQuery method” on page 33 “Retrieving data from tables using the Statement.executeQuery method” on page 32 “Calling stored procedures in JDBC applications” on page 45 “Writing a Java stored procedure to return result sets”...
Page 64
rs.close(); // Close the result set cstmt.close(); // Close the statement Retrieving an unknown number of result sets from a stored procedure in a JDBC application: Retrieving an unknown number of result sets from a stored procedure is a more complicated procedure than retrieving a known number of result sets.
DB2 for z/OS Version 9.1 and later supports progressive streaming for LOBs and XML objects. DB2 Database for Linux, UNIX, and Windows Version 9.5 and later, IBM Informix Dynamic Server (IDS) Version 11.50 and later, and DB2 for i V6R1 and later support progressive streaming for LOBs.
Page 66
IBM Informix Dynamic Server (IDS) Version 11.50 and later support progressive streaming for LOBs. For DB2 for z/OS Version 9.1 and later data sources, or DB2 Database for Linux, UNIX, and Windows Version 9.5 and later data sources: v If the IBM Data Server Driver for JDBC and SQLJ progressiveStreaming property is DB2BaseDataSource.YES, your application uses progressive streaming...
Page 67
LOB locators with the IBM Data Server Driver for JDBC and SQLJ The IBM Data Server Driver for JDBC and SQLJ can use LOB locators to retrieve data in LOB columns. You should use LOB locators only if the data source does not support progressive streaming.
Page 68
– setCharacterStream – setObject, where the Object parameter value is a Reader. If you specify -1 for length, the IBM Data Server Driver for JDBC and SQLJ reads the input data until it is exhausted. v Retrieve the value of a JDBC CLOB parameter using the CallableStatement.getString method.
Page 69
LOB column, you need to choose a parameter data type that is compatible with the LOB data type. For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS, when the JDBC driver processes a CallableStatement.setXXX call for a stored procedure input parameter, or a CallableStatement.registerOutParameter...
Page 70
v Use the CallableStatement.registerOutParameter call to specify that an output parameter is of type BLOB. Then you can retrieve the parameter value into any variable that has a data type that is compatible with a BLOB data type. For example, the following code lets you retrieve a BLOB value into a byte[] variable: cstmt.registerOutParameter(parmIndex, java.sql.Types.BLOB);...
ROWID columns. If you are using JDBC 3.0, for getObject, the IBM Data Server Driver for JDBC and SQLJ returns an instance of the IBM Data Server Driver for JDBC and SQLJ-only class com.ibm.db2.jcc.DB2RowID.
If you are using JDBC 3.0, for setObject, use the IBM Data Server Driver for JDBC and SQLJ-only type com.ibm.db2.jcc.Types.ROWID or an instance of the com.ibm.db2.jcc.DB2RowID class as the target type for the parameter. If you are using JDBC 4.0, for setObject, use the type java.sql.Types.RowId or an instance of the java.sql.ROWID class as the target type for the parameter.
Sets a savepoint. These methods return a Savepoint object that is used in later releaseSavepoint or rollback operations. When you execute either of these methods, DB2 executes the form of the SAVEPOINT statement that includes ON ROLLBACK RETAIN CURSORS. Chapter 3. JDBC application programming...
“Data types that map to database data types in Java applications” on page 193 Retrieving automatically generated keys in JDBC applications With the IBM Data Server Driver for JDBC and SQLJ, you can retrieve automatically generated keys (also called auto-generated keys) from a table using JDBC 3.0 methods.
Page 75
Restriction: You cannot prepare an SQL statement for retrieval of automatically generated keys and use the PreparedStatement object for batch updates. The IBM Data Server Driver for JDBC and SQLJ version 3.50 or later throws an SQLException when you call the addBatch or executeBatch method on a PreparedStatement object that is prepared to return automatically generated keys.
3. Call any of the methods shown in Table 10. 4. Execute an SQL statement to cause the information to be sent to the DB2 server. The following code performs the previous steps to pass a user name and a workstation name to the DB2 server.
Providing extended client information to the data source with client info properties The IBM Data Server Driver for JDBC and SQLJ version 4.0 supports JDBC 4.0 client info properties, which you can use to provide extra information about the client to the server. This information can be used for accounting, workload management, or debugging.
Page 79
Driver for JDBC and SQLJ returns for DB2 Database for Linux, UNIX, and Windows and for DB2 for i. Table 11. Client info property values for DB2 Database for Linux, UNIX, and Windows and for DB2 for i NAME MAX_LEN...
Page 80
The following table lists the client info property values that the IBM Data Server Driver for JDBC and SQLJ returns for DB2 for z/OS Table 12. Client info property values for DB2 for z/OS DEFAULT_VALUE for type 2 NAME MAX_LEN DEFAULT_VALUE for type 4 connectivity...
XML data in JDBC applications In JDBC applications, you can store data in XML columns and retrieve data from XML columns. In database tables, the XML built-in data type is used to store XML data in a column as a structured set of nodes in a tree format. In applications, XML data is in the serialized string format.
Page 82
The data source handles incompatibilities between internal and external encoding as follows: v If the data source is DB2 Database for Linux, UNIX, and Windows, the database source generates an error if the external and internal encoding are incompatible, unless the external and internal encoding are Unicode. If the external and internal encoding are Unicode, the database source ignores the internal encoding.
The In JDBC applications, you use ResultSet.getXXX or ResultSet.getObject methods to retrieve data from XML columns. When you retrieve data from XML columns of a DB2 table, the output data is in the serialized string format. This is true whether you retrieve the entire contents of an XML column or a sequence from the column.
Page 84
String The following table lists the methods that you can call to retrieve data from a java.sql.SQLXML or a com.ibm.db2.jcc.DB2Xml object, and the corresponding output data types and type of encoding in the XML declarations. Table 16. SQLXML and DB2Xml methods, data types, and added encoding specifications...
Page 85
If the application executes the XMLSERIALIZE function on the data that is to be returned, after execution of the function, the data has the data type that is specified in the XMLSERIALIZE function, not the XML data type. Therefore, the driver handles the data as the specified type and ignores any internal encoding declarations.
Page 86
(rs.next()) { // Retrieve the XML data with getObject, and cast the object // as a DB2Xml object. Then write it to a string with // explicit internal ISO-10646-UCS-2 encoding. com.ibm.db2.jcc.DB2Xml xml = (com.ibm.db2.jcc.DB2Xml) rs.getObject(1); System.out.println (xml.getDB2XmlString()); rs.close(); catch (SQLException sqle) { System.out.println("fetchToDB2Xml: SQL Exception: "...
DB2 will not find this XML schema on an invocation of DSN_XMLVALIDATE that supplies a non-null XML schema location value. No additional properties are registered. Figure 22. Example of registration of an XML schema with DB2 using an XML document from an input stream public static void registerSchema( Connection con,...
Page 88
Example: Removal of an XML schema: The following example demonstrates the use of deregisterDB2XmlObject to remove an XML schema from DB2. The SQL schema name for the registered schema is SYSXSR. Figure 23. Example of removal of an XML schema from DB2...
IBM Data Server Driver for JDBC and SQLJ isolation levels The IBM Data Server Driver for JDBC and SQLJ supports a number of isolation levels, which correspond to database server isolation levels. JDBC isolation levels can be set for a unit of work within a JDBC program, using the Connection.setTransactionIsolation method.
The default autocommit mode depends on the data source to which the JDBC application connects. Autocommit default for DB2 data sources For connections to DB2 data sources, the default autocommit mode is true. Autocommit default for IDS data sources For connections to IDS data sources, the default autocommit mode depends on the type of data source.
SQL warnings do not throw exceptions, so you need to invoke methods to check whether warnings occurred after you execute SQL statements. The IBM Data Server Driver for JDBC and SQLJ provides the following classes and interfaces, which provide information about errors and warnings.
Page 92
v The SQLSTATE getThrowable Returns a java.lang.Throwable object that caused the SQLException, or null, if no such object exists. printTrace Prints diagnostic information. SQLException subclasses If you are using JDBC 4.0 or later, you can obtain more specific information than an SQLException provides by catching the following exception classes: v SQLNonTransientException An SQLNonTransientException is thrown when an SQL operation that failed...
PreparedStatement.executeUpdate affects no rows, the IBM Data Server Driver for JDBC and SQLJ generates an SQLWarning with error code +100. When a call to ResultSet.next returns no rows, the IBM Data Server Driver for JDBC and SQLJ does not generate an SQLWarning.
Page 94
2. Optional: During a connection to a DB2 for z/OS or IBM Informix Dynamic Server (IDS) data source, set the retrieveMessagesFromServerOnGetMessage property to true if you want full message text from an SQLException.getMessage call. 3. Optional: During a IBM Data Server Driver for JDBC and SQLJ type 2...
Page 95
SQLJ-specific information from an SQLException that is provided with the IBM Data Server Driver for JDBC and SQLJ. The numbers to the right of selected statements correspond to the previously-described steps. Figure 25. Processing an SQLException under the IBM Data Server Driver for JDBC and SQLJ import java.sql.*;...
Page 96
“Handling SQL errors in an SQLJ application” on page 154 “Handling SQL warnings in an SQLJ application” on page 155 Related reference “Error codes issued by the IBM Data Server Driver for JDBC and SQLJ” on page 382 “DB2Diagnosable interface” on page 344 “DB2Sqlca class”...
1. Optional: During connection to the database server, set properties that affect SQLWarning objects. If you want full message text from a DB2 for z/OS or IBM Informix Dynamic Server (IDS) data source when you execute SQLWarning.getMessage calls, set the retrieveMessagesFromServerOnGetMessage property to true.
Related concepts “Example of a simple JDBC application” on page 7 Related tasks “Handling an SQLException under the IBM Data Server Driver for JDBC and SQLJ” on page 77 Retrieving information from a BatchUpdateException When an error occurs during execution of a statement in a batch, processing continues.
Page 99
Each ResultSet contains: v If the ResultSet is not null, it contains the automatically generated keys for an execution of the batched SQL statement. v If the ResultSet is null, an error occurred during retrieval of the automatically generated keys for the SQL statement. 3.
DB2 Connect gateway, with the following exception: If you set the alternate DB2 Connect gateway on the client side in one of the following ways, the driver fails over to an alternate DB2 Connect gateway for the...
Configuration of DB2 for z/OS servers for client reroute If Sysplex routing is disabled on a DB2 for z/OS server, and a data sharing group is set up for member-specific access, you can use IBM Data Server Driver for JDBC and SQLJ client reroute support.
Page 102
The following code sets up DataSource properties in an application so that the application connects to mvs1.sj.ibm.com as the primary server, and mvs3.sj.ibm.com as the alternative server. That is, if mvs1.sj.ibm.com is down during the initial connection, the driver should connect to mvs3.sj.ibm.com.
IBM Informix Dynamic Server (IDS) servers, you need to connect to a Connection Manager. Before you can enable IBM Data Server Driver for JDBC and SQLJ client reroute for connections to IBM Informix Dynamic Server, your installation must have one or more Connection Managers, a primary server, and one or more alternate servers.
Page 104
The alternative Connection Managers are used for the initial connection only, unless seamless failover is enabled. For the initial connection, if the main Connection Manager is down, the IBM Data Server Driver for JDBC and SQLJ attempts to make a connection to the Connection Manager that is specified by the...
If you make connections with the javax.sql.DataSource, javax.sql.ConnectionPoolDataSource, or javax.sql.XADataSource interface, you indicate to the IBM Data Server Driver for JDBC and SQLJ that JNDI is configured for client reroute by setting the clientRerouteServerListJNDIName property. You can also specify the clientRerouteServerListJNDIContext property, which provides the JNDI context that is used for binding and lookup of a DB2ClientRerouteServerList instance.
1. During each connection to the data source, the IBM Data Server Driver for JDBC and SQLJ obtains primary and alternate server information. v For the first connection to a DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows server: a.
Page 107
For subsequent connections, the IBM Data Server Driver for JDBC and SQLJ obtains primary and alternate server values from driver memory. 2. The IBM Data Server Driver for JDBC and SQLJ attempts to connect to the data source using the primary server name and port number.
Page 108
If reconnection to the primary server fails, the IBM Data Server Driver for JDBC and SQLJ attempts to connect to the alternate servers. If this is not the first connection, the latest alternate server list is used to find the next alternate server.
Page 109
The following steps demonstrate a client reroute scenario for a connection to a DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows server: 1. The IBM Data Server Driver for JDBC and SQLJ loads host1:port1 into its memory as the primary server address, and host2:port2 into its memory as the alternate server address.
Page 110
The following steps demonstrate a client reroute scenario for a connection to a DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows server: 1. The IBM Data Server Driver for JDBC and SQLJ loads host1:port1 into its memory as the primary server address, and host2:port2 into its memory as the alternate server address.
1. The IBM Data Server Driver for JDBC and SQLJ tries to connect to the Connection Manager that is identified by host1:port1. 2. The connection to host1:port1 fails, so the driver tries to connect to the Connection Manager that is identified by host2:port2.
Page 112
If client affinities for cascaded failover is enabled, the IBM Data Server Driver for JDBC and SQLJ retries connections to only those servers that are identified by the clientRerouteAlternateServerName and clientRerouteAlternatePortNumber properties.
When you use IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS, you can configure connections to a data sharing group so that when a connection to a data sharing member fails, new connections switch automatically to an alternative member of the DB2 data sharing group that is running on the same LPAR.
LOB types with large length attributes. Even when you use a 64-bit JVM, all native connectivity to DB2 for z/OS is below the bar, with 32-bit addressing limits. Although the maximum size of any row is defined as...
To close the connection to the data source, use the close method. For example: Connection con; con.close(); For a connection to a DB2 data source, if autocommit mode is not on, the connection needs to be on a unit-of-work boundary before you close the connection.
Page 116
™ Application Programming Guide and Reference for Java...
In general, you need to do the following things: v Import the Java packages that contain SQLJ and JDBC methods. v Declare variables for sending data to or retrieving data from DB2 tables. v Connect to a data source. v Execute SQL statements.
Page 118
EzSqljNameIter iter; int count=0; #sql [ctx] iter = {SELECT LASTNAME FROM EMPLOYEE}; // Create result table of the SELECT while (iter.next()) { System.out.println(iter.LASTNAME()); // Retrieve rows from result table count++; System.out.println("Retrieved " + count + " rows of data"); catch( SQLException e ) System.out.println ("**** SELECT SQLException...");...
“Closing the connection to a data source in an SQLJ application” on page 156 Connecting to a data source using SQLJ In an SQLJ application, as in any other DB2 application, you must be connected to a data source before you can execute SQL statements.
A string that specifies the location name that is associated with the data source. That argument has one of the forms that are specified in ″Connect to a data source using the DriverManager interface with the IBM Data Server Driver for JDBC and SQLJ″. The form depends on which JDBC driver you are using.
If the data source is a DB2 for z/OS system, and you do not specify these parameters, DB2 uses the external security environment, such as the RACF security environment, that was previously established for the user. For a CICS connection, you cannot specify a user ID or password.
Page 122
Specify a user ID and password for connection to the data source, if the data source to which you are connecting requires them. If the data source is a DB2 for z/OS system, and you do not specify these parameters, DB2 uses the external security environment, such as the RACF security environment, that was previously established for the user.
Specify a user ID and password for connection to the data source, if the data source to which you are connecting requires them. If the data source is a DB2 for z/OS system, and you do not specify these parameters, DB2 uses the external security environment, such as the RACF security environment, that was previously established for the user.
The following code uses connection technique 3 to create a connection to a location with logical name jdbc/sampledb. This example assumes that the system administrator created and deployed a DataSource object that is available through JNDI lookup. The numbers to the right of selected statements correspond to the previously-described steps.
If the data source is a DB2 for z/OS system, and you do not specify these parameters, DB2 uses the external security environment, such as the RACF security environment, that was previously established for the user. For a CICS connection, you cannot specify a user ID or password.
ConnectionContext.setDefaultContext method. This method of creating a default connection context is not recommended. In a stored procedure that runs on DB2 for z/OS, or for a CICS or IMS application, when you use the default connection, DB2 uses the implicit connection.
Page 127
Evaluates side effects, such as operations with postfix operators, according to normal Java rules. All host expressions are fully evaluated before any of their values are passed to DB2. v Uses Java rules for rounding and truncation. Therefore, if the value of yearsEmployed is 6 before the UPDATE statement is executed, the value that is assigned to column BONUS by the UPDATE statement is ((int)6/5)*500, or 500.
v The string __sJT_ is a reserved prefix for variable names that are generated by SQLJ. Do not begin the following types of names with __sJT_: – Host expression names – Java variable names that are declared in blocks that include executable SQL statements –...
“Retrieving multiple result sets from a stored procedure in an SQLJ application” on page 134 “LOBs in SQLJ applications with the IBM Data Server Driver for JDBC and SQLJ” on page 136 “SQLJ and JDBC in the same application” on page 139 Related tasks “Calling stored procedures in an SQLJ application”...
If the statement executes dynamically the authorization ID is determined by the DYNAMICRULES behavior that is in effect. For the IBM Data Server Driver for JDBC and SQLJ, the behavior is always DYNAMICRULES BIND.
Page 131
c. If the iterator is pointing to a row of the result table, execute an SQL UPDATE... WHERE CURRENT OF :iterator-object statement in an executable clause to update the columns in the current row. Execute an SQL DELETE... WHERE CURRENT OF :iterator-object statement in an executable clause to delete the current row.
Page 132
// was created by the iterator declaration clause // for UpdByName in another file #sql context HSCtx; // Create a connnection context class HSCtx public static void main (String args[]) try { Class.forName("com.ibm.db2.jcc.DB2Driver"); catch (ClassNotFoundException e) { e.printStackTrace(); Connection HSjdbccon= DriverManager.getConnection("jdbc:db2:SANJOSE"); // Create a JDBC connection object HSjdbccon.setAutoCommit(false);...
Page 133
“Data retrieval in SQLJ applications” on page 123 ″Authorization IDs and dynamic SQL″ (DB2 SQL Reference) Related tasks “Creating and modifying DB2 objects in an SQLJ application” on page 113 “Connecting to a data source using SQLJ” on page 103 Chapter 4. SQLJ application programming...
Page 134
“Using a named iterator in an SQLJ application” on page 124 “Using a positioned iterator in an SQLJ application” on page 126 Related reference “SQLJ implements-clause” on page 282 “SQLJ with-clause” on page 283 “sqlj.runtime.ForUpdate interface” on page 298 Iterators as passed variables for positioned UPDATE or DELETE operations in an SQLJ application SQLJ allows iterators to be passed between methods as variables.
Page 135
You can avoid a bind time error for a program like the one in Figure 36 on page 118 by specifying the bind option SQLERROR(CONTINUE). However, this technique has the drawback that it causes the DB2 database manager to build a package, regardless of the SQL errors that are in the program. A better technique is to write the program so that there is a one-to-one mapping between tables in positioned UPDATE or DELETE statements and iterator classes.
Page 136
v Different statements v Statements with different numbers of input parameters or host expressions v Statements with different data types for input parameters or host expressions v Statements with no input parameters or host expressions When an error occurs during execution of a statement in a batch, the remaining statements are executed, and a BatchUpdateException is thrown after all the statements in the batch have executed.
Page 137
Other integer This value is the number of rows that were updated by the statement. This value is returned if the statement was executed rather than added to a batch. 5. Execute the batch explicitly or implicitly. v Invoke the ExecutionContext.executeBatch method to execute the batch explicitly.
Page 138
Do this by invoking the ExecutionContext.setBatching(false) method. When you disable batching, you can still execute the batch implicitly or explicitly, but no more statements are added to the batch. Disabling batching is useful when a batch already exists, and you want to execute a batch compatible statement, rather than adding it to the batch.
SQLJ applications use a result set iterator to retrieve result sets. Like a cursor, a result set iterator can be non-scrollable or scrollable. Just as in DB2 applications in other languages, if you want to retrieve a single row from a table in an SQLJ application, you can write a SELECT INTO statement with...
Page 140
DB2 column data types. See ″Java, JDBC, and SQL data types″ for a list of the best mappings between Java data types and DB2 data types. You can declare an iterator in a number of ways. However, because a Java class underlies each iterator, you need to ensure that when you declare an iterator, the underlying class obeys Java rules.
Page 141
When you declare an iterator in this way, you can instantiate it only within an instance of the nesting class. However, you can declare the iterator and other classes in the file as public. You cannot cast a JDBC ResultSet to an iterator if the iterator is declared as an inner class.
Page 142
DB2 column data types. See ″Java, JDBC, and SQL data types″ for a list of the best mappings between Java data types and DB2 data types. You can declare an iterator in a number of ways. However, because a Java class underlies each iterator, you need to ensure that when you declare an iterator, the underlying class obeys Java rules.
Page 143
v As a nested static class within another class Using this alternative lets you combine the iterator declaration with other class declarations in the same source file, declare the iterator and other classes as public, and make the iterator class visible from other code modules or packages.
Page 144
For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS, support for multiple open iterators on a single SQL statement must be enabled.
Page 145
Without the capability for multiple, concurrently open iterators for a single SQL statement, if you want to select employee and salary values for a specific employee number, you need to define a different SQL statement for each employee number, as shown in Figure 41. MultiIter iter1 = null;...
Page 146
Using scrollable iterators in an SQLJ application In addition to moving forward, one row at a time, through a result table, you might want to move backward or go directly to a specific row. The IBM Data Server Driver for JDBC and SQLJ provides this capability.
Page 147
(sensitivity=INSENSITIVE) (String EmpNo); Restriction: You cannot use a scrollable iterator to select columns with the following data types from a table on a DB2 Database for Linux, UNIX, and Windows server: v LONG VARCHAR v LONG VARGRAPHIC...
Page 148
Before the first row in the result table beforeFirst Notes: 1. This method does not apply to connections to IBM Informix Dynamic Server. 2. If the cursor is after the last row of the result table, this method positions the cursor on the last row.
Page 149
Before the first row in the result table Notes: 1. This value is not supported for connections to IBM Informix Dynamic Server 2. If the cursor is after the last row of the result table, this method positions the cursor on the last row.
To call a stored procedure, you use an executable clause that contains an SQL CALL statement. You can execute the CALL statement with host identifier parameters. You can execute the CALL statement with literal parameters only if the DB2 server on which the CALL statement runs supports execution of the CALL statement dynamically.
Page 151
2. Associate the execution context with the CALL statement for the stored procedure. Do not use this execution context for any other purpose until you have retrieved and processed the last result set. 3. For each result set: a. Use the ExecutionContext method getNextResultSet to retrieve the result set.
LOBs in SQLJ applications with the IBM Data Server Driver for JDBC and SQLJ With the IBM Data Server Driver for JDBC and SQLJ, you can retrieve LOB data into Clob or Blob host expressions or update CLOB, BLOB, or DBCLOB columns from Clob or Blob host expressions.
Page 153
This extra processing can impact performance. For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS, when the JDBC driver processes a CALL statement, the driver cannot determine the parameter data types.
Page 154
Before you can use a java.sql.Clob input variable, you need to create a java.sql.Clob object, and then populate that object. For example, if you are using IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS, you can use the IBM Data Server Driver for JDBC and SQLJ-only method com.ibm.db2.jcc.t2zos.DB2LobFactory.createClob to...
DBCLOB output or input/output parameters for stored procedures are not supported. Related concepts “LOBs in SQLJ applications with the IBM Data Server Driver for JDBC and SQLJ” on page 136 Related reference “Data types that map to database data types in Java applications” on page 193 SQLJ and JDBC in the same application You can combine SQLJ clauses and JDBC calls in a single program.
Page 156
v If the iterator is a positioned iterator, the number of columns in the result set must match the number of columns in the iterator. In addition, the data type of each column in the result set must match the data type of the corresponding column in the iterator.
Page 157
ResultSet object. Closing the generated ResultSet object also closes the iterator object. In general, it is best to close the object that is used last. v For the IBM Data Server Driver for JDBC and SQLJ, which supports scrollable iterators and scrollable and updatable ResultSets, the following restrictions apply: –...
“SQLJ with-clause” on page 283 “SQLJ assignment-clause” on page 291 “sqlj.runtime.ConnectionContext interface” on page 293 ″DESCRIBE FOR STATIC″ (DB2 Installation Guide) Controlling the execution of SQL statements in SQLJ You can use selected methods of the SQLJ ExecutionContext class to control or monitor the execution of SQL statements.
ROWIDs in SQLJ with the IBM Data Server Driver for JDBC and SQLJ DB2 for z/OS and DB2 for i5/OS support the ROWID data type for a column in a table. A ROWID is a value that uniquely identifies a row in a table.
" Shoe size: " + shoeSizeVar); Figure 50. Defining and using a distinct type Related reference “Data types that map to database data types in Java applications” on page 193 ″CREATE TYPE″ (DB2 SQL Reference) ™ Application Programming Guide and Reference for Java...
In SQLJ applications, you can store data in XML columns and retrieve data from XML columns. In DB2 tables, the XML built-in data type is used to store XML data in a column as a structured set of nodes in a tree format.
The host expression data types that you can use to update XML columns are: v java.sql.SQLXML (requires an SDK for Java Version 6 or later, and the IBM Data Server Driver for JDBC and SQLJ version 4.0 or later) v com.ibm.db2.jcc.DB2Xml (deprecated)
Page 163
If the data source is DB2 Database for Linux, UNIX, and Windows, the data source generates an error if the external and internal encoding are incompatible, unless the external and internal encoding are Unicode. If the external and internal encoding are Unicode, the data source ignores the internal encoding.
The host expression or iterator data types that you can use to retrieve data from XML columns are: v java.sql.SQLXML (requires an SDK for Java Version 6 or later, and the IBM Data Server Driver for JDBC and SQLJ version 4.0 or later) v com.ibm.db2.jcc.DB2Xml (deprecated)
Page 165
Table 22. SQLXML and DB2Xml methods, data types, and added encoding specifications (continued) Method Output data type Type of XML internal encoding declaration added SQLXML.getCharacterStream Reader None SQLXML.getSource Source None SQLXML.getString String None DB2Xml.getDB2AsciiStream InputStream None DB2Xml.getDB2BinaryStream InputStream None DB2Xml.getDB2Bytes byte[] None DB2Xml.getDB2CharacterStream...
The SQLXML.getBinaryStream stores the data in a binary stream. Example: Suppose that you retrieve a document from an XML column into a com.ibm.db2.jcc.DB2Xml host expression, but you need the data in a byte string with an XML declaration that includes an internal encoding specification for UTF-8.
Page 167
Annotations Java annotations are a means for adding metadata to Java programs that can also affect the way that those programs are treated by tools and libraries. Annotations are declared with annotation type declarations, which are similar to interface declarations. Java annotations can appear in the following types of classes or interfaces: v Class declaration v Interface declaration...
Page 168
public class TestEnum2 public enum Color { RED,ORANGE,YELLOW,GREEN,BLUE,INDIGO,VIOLET} Color color = null; switch (color) { case RED: System.out.println("Red is at one end of the spectrum."); #sql[ctx] { INSERT INTO MYTABLE VALUES (:color) }; break; case VIOLET: System.out.println("Violet is on the other end of the spectrum."); break;...
To set the isolation level for a unit of work within an SQLJ program, use the SET TRANSACTION ISOLATION LEVEL clause. The following table shows the values that you can specify in the SET TRANSACTION ISOLATION LEVEL clause and their DB2 equivalents. Table 23. Equivalent SQLJ and DB2 isolation levels SET TRANSACTION value...
You can use the getErrorCode method to retrieve SQL error codes and the getSQLState method to retrieve SQLSTATEs. If you are using the IBM Data Server Driver for JDBC and SQLJ, obtain additional information from the SQLException by casting it to a DB2Diagnosable object, in the same way that you obtain this information in a JDBC application.
388 Handling SQL warnings in an SQLJ application Other than a +100 SQL error code on a SELECT INTO statement, DB2 warnings do not throw SQLExceptions. To handle DB2 warnings, you need to give the program access to the java.sql.SQLWarning class.
When you have finished with a connection to a data source, you need to close the connection to the data source. Doing so releases the connection context object’s DB2 and SQLJ resources immediately. To close the connection to the data source, use one of the ConnectionContext.close methods.
This topic discusses the setup tasks for preparing and running Java routines. If you plan to use IBM Data Studio to prepare and run your Java routines, see the information on developing database routines in the IBM Data Studio information center, at the following URL: http://publib.boulder.ibm.com/infocenter/dstudio/v1r1m0/index.jsp...
Figure 52. Startup procedure for a WLM address space in which a Java routine runs Notes to Figure 52: In this line, change the DB2SSN value to your DB2 for z/OS subsystem name. Change the APPLENV value to the name of the application environment that you set up for Java stored procedures.
Page 175
Specifies a data set into which DB2 puts information that you can use to debug your stored procedure. The information that DB2 collects is for assistance in debugging setup problems, and should be used only under the direction of IBM Software Support.
Start Parameters If the DB2 subsystem in which the stored procedure runs is not in a Sysplex, the DB2SSN value must match the name of that DB2 subsystem. If the same JCL is used for multiple DB2 subsystems, specify DB2SSN=&IWMSSNM.
Page 177
JAVAENV data set for Java stored procedures is 245 bytes. If you exceed the maximum length, DB2 truncates the contents but does not issue a message. If you enter the contents of the JAVAENV data set on more than one line, DB2 concatenates the lines to form the run-time options string.
Page 178
Modify LC_ALL to change the locale to use for the locale categories when the individual locale environment variables specify locale information. This value needs to match the CCSID for the DB2 subsystem on which the stored procedures run. For example: LC_ALL=En_US.IBM-037...
Page 179
“WLM address space startup procedure for Java routines” on page 158 “WLM application environment values for Java routines” on page 159 “Techniques for testing a Java routine” on page 179 “Environment variables for the IBM Data Server Driver for JDBC and SQLJ” on page 415 Related tasks...
DB2 catalogs. Definition of a Java routine to DB2 Before you can use a Java routine, you need to define it to DB2 using the CREATE PROCEDURE or CREATE FUNCTION statement. The definition for a Java routine is much like the definition for a routine in any other language.
Page 181
For compatibility with DB2 Database for Linux, UNIX, and Windows, you can use an exclamation point (!) after JAR-name instead of a colon. For compatibility with previous versions of DB2, you can use a slash (/) after package-name instead of a period.
Page 182
LANGUAGE JAVA, DB2 issues an error. SCRATCHPAD Specifies that when the user-defined function is invoked for the first time, DB2 allocates memory for a scratchpad. You cannot use a scratchpad in a Java user-defined function. Do not specify SCRATCHPAD when you create or alter a Java user-defined function.
Page 183
Type of SQL statements in the program Statements that modify DB2 tables WLM environment name WLMIJAV Maximum number of result sets returned This CREATE PROCEDURE statement defines the stored procedure to DB2: CREATE PROCEDURE SYSPROC.S1SAL (DECIMAL(10,2) INOUT) FENCED MODIFIES SQL DATA...
One way to organize the classes for a Java routine is to collect those classes into a JAR file. If you do this, you need to install the JAR file into the DB2 catalog. DB2 provides built-in stored procedures that perform the following functions for the JAR file: SQLJ.INSTALL_JAR...
Page 185
Modifies the class resolution path of an previously installed JAR file to a specified value. You can use IBM Data Studio to install JAR files into the DB2 catalog, or you can write a client program that executes SQL CALL statements to invoke these stored procedures.
Page 186
SQLJ.INSTALL_JAR parameters url A VARCHAR(1024) input parameter that identifies the z/OS UNIX System Services full path name for the JAR file that is to be installed in the DB2 catalog. The format is file://path-name or file:/path-name. JAR-name A VARCHAR(257) input parameter that contains the DB2 name of the JAR, in the form schema.JAR-id or JAR-id.
Page 187
JAR-id. This is the name that you use when you refer to the JAR in SQL statements. If you omit schema, DB2 uses the SQL authorization ID that is in the CURRENT SCHEMA special register. The owner of the JAR is the authorization ID in the CURRENT SQLID special register.
Page 188
A VARCHAR(257) input parameter that contains the DB2 name of the JAR, in the form schema.JAR-id or JAR-id. This is the name that you use when you refer to the JAR in SQL statements. If you omit schema, DB2 uses the SQL authorization ID that is in the CURRENT SCHEMA special register.
Page 189
SQLJ.REMOVE_JAR parameters JAR-name A VARCHAR(257) input parameter that contains the DB2 name of the JAR that is to be removed from the catalog, in the form schema.JAR-id or JAR-id. This is the name that you use when you refer to the JAR in SQL statements. If you omit schema, DB2 uses the SQL authorization ID that is in the CURRENT SCHEMA special register.
Page 190
JAR-id. This is the name that you use when you refer to the JAR in SQL statements. If you omit schema, DB2 uses the SQL authorization ID that is in the CURRENT SCHEMA special register.
JAR-name2 Specifies the DB2 name of the JAR that is to be searched. The form of JAR-name2 is schema.JAR-id or JAR-id. If schema is omitted, the JAR name is implicitly qualified with the schema name in the CURRENT SCHEMA special register.
A Java routine must be defined with PARAMETER STYLE JAVA. PARAMETER STYLE JAVA specifies that the routine uses a parameter-passing convention that conforms to the Java language and SQLJ specifications. DB2 passes INOUT and OUT parameters as single-entry arrays. This means that in your Java routine, you must declare OUT or INOUT parameters as arrays.
SQL error condition is reported. Related concepts “Differences between Java routines and stand-alone Java programs” on page ″Creating an external stored procedure″ (DB2 Application Programming and SQL Guide) ″Writing an external user-defined function″ (DB2 Application Programming and SQL Guide) Related tasks “Writing a Java stored procedure to return result sets”...
5. Do not close the ResultSet, the statement that generated the ResultSet, or the connection that is associated with the statement that generated the ResultSet. DB2 does not return result sets for ResultSets that are closed before the stored procedure terminates.
Techniques for testing a Java routine The most common techniques for testing a Java routine are testing the routine as a stand-alone program, using the DB2 Unified Debugger, enabling collection of DB2 debug information, and testing the routine as a stand-alone program, and writing your own debug information from your routine.
Page 196
A Java program that runs as a routine requires only a DB2 package. However, before you can run the program as a stand-alone program, you need to bind a DB2 plan for it. Use the DB2 Unified Debugger (stored procedures only) The DB2 Unified Debugger is available with DB2 Database for Linux, UNIX, and Windows.
Page 197
STDERR and STDOUT output is written to the directory that is specified by the WORK_DIR parameter in the JAVAENV data set, if that directory exists. If no WORK_DIR parameter is specified, output goes to the default directory, /tmp/java, if that directory exists. Related concepts “Run-time environment for Java routines”...
Page 198
™ Application Programming Guide and Reference for Java...
Chapter 6. Preparing and running JDBC and SQLJ programs DB2 for z/OS Java programs run in the z/OS UNIX System Services environment. The following topics contain information about preparing and running Java programs. Program preparation for JDBC programs Preparing a Java program that contains only JDBC methods is the same as preparing any other Java program.
Page 200
Optionally binds DB2 packages on a specified database server. The default behavior is to bind the DB2 packages. However, you can disable automatic creation of packages and use the db2sqljbind command to bind the packages later.
“db2sqljbind - SQLJ profile binder” on page 407 Binding SQLJ applications to access multiple database servers After you prepare an SQLJ program to run on one DB2 database server, you might want to port that application to other environments that access different database servers.
Page 202
MYCOL2 collection for the packages. Use one of the following methods to bind the packages: v Run DB2 BIND with COPY to copy each of the packages (one for each isolation level) from the ZOS1 system to the ZOS2 system: BIND PACKAGE (ZOS2.MYCOL2) OWNER(USER01) QUALIFIER(WRK2) -...
SQLJ.ALTER_JAVA_PATH stored procedure to specify the class resolution path that the JVM searches to resolve those class references. 5. If another user defines the routine to DB2, execute the SQL GRANT USAGE ON JAR statement to grant the privilege to use the JAR file to that user.
“Definition of a JAR file for a Java routine to DB2” on page 168 Related tasks “Creating JAR files for Java routines” on page 191 Preparing Java routines with no SQLJ clauses and no JAR file The program preparation process for Java routines that contain no SQLJ clauses and do not run from a JAR file includes compiling the program, defining the routine to DB2, and granting the appropriate privileges.
Page 205
SQLJ.ALTER_JAVA_PATH stored procedure to specify the class resolution path that the JVM searches to resolve those class references. 6. If another user defines the routine to DB2, execute the SQL GRANT USAGE ON JAR statement to grant the privilege to use the JAR file to that user.
Page 206
You need to execute the CALL statement from a static SQL program or from an ODBC or JDBC program. 6. If another user defines the routine to DB2, on DB2 for z/OS, execute the SQL GRANT USAGE ON JAR statement to grant the privilege to use the JAR file to that user.
WLM address space to make it use the modified CLASSPATH. 4. Use the SQL CREATE PROCEDURE or CREATE FUNCTION statement to define the routine to DB2. Specify the EXTERNAL NAME parameter without a JAR name. 5. Execute the SQL GRANT statement to grant the EXECUTE privilege on the routine to the appropriate users.
To run a program that is in the EzJava class, add the directory that contains EzJava to the CLASSPATH. Then run this command: java EzJava Related concepts “Environment variables for the IBM Data Server Driver for JDBC and SQLJ” on page 415 ™ Application Programming Guide and Reference for Java...
Java data types and table column data types. The following tables summarize the mappings of Java data types to JDBC and database data types for a DB2 Database for Linux, UNIX, and Windows, DB2 for z/OS, or IBM Informix Dynamic Server (IDS) system.
Page 210
9. This mapping is valid only if the database server can determine the data type of the column. 10. XML is valid for connections to DB2 Version 9.1 for z/OS or later database servers or DB2 V9.1 for Linux, UNIX, and Windows or later database servers.
Page 211
Table 26. Mappings of database server data types to Java data types for retrieving data from database server tables Recommended Java data type or SQL data type Java object type Other supported Java data types SMALLINT short byte, int, long, float, double, java.math.BigDecimal, boolean, java.lang.String INTEGER...
Page 212
3. This mapping is valid only if the database server can determine the data type of the column. 4. XML is valid for connections to DB2 Version 9.1 for z/OS or later database servers or DB2 V9.1 for Linux, UNIX, and Windows or later database servers.
Page 213
Table 27. Mappings of Java, JDBC, and SQL data types for calling stored procedures and user-defined functions (continued) Java data type JDBC data type SQL data type java.math.BigDecimal DECIMAL DECIMAL java.math.BigDecimal java.types.OTHER DECFLOATn | | | java.math.BigDecimal com.ibm.db2.jcc.DB2Types.DECFLOAT DECFLOATn java.lang.String CHAR CHAR java.lang.String CHAR GRAPHIC java.lang.String VARCHAR VARCHAR java.lang.String VARCHAR VARGRAPHIC java.lang.String...
Page 214
V9.1 for Linux, UNIX, and Windows or later database servers, and DB2 for i5/OS V5R3 and later database servers. 6. BIGINT is valid for connections to DB2 Version 9.1 for z/OS or later database servers, DB2 V9.1 for Linux, UNIX, and Windows or later database servers, and all supported DB2 for i database servers.
Page 215
1. A DB2 for z/OS stored procedure or user-defined function parameter cannot have the XML data type. 2. For a stored procedure or user-defined function on a DB2 Database for Linux, UNIX, and Windows server, only the first data type is valid.
In particular, using the hour ’24’ to represent midnight can cause problems. The IBM Data Server Driver for JDBC and SQLJ uses Java data types for its internal processing of input and output parameters and ResultSet content in JDBC and SQLJ applications.
SQLJ and earlier DB2 JDBC drivers” on page 370 Properties for the IBM Data Server Driver for JDBC and SQLJ IBM Data Server Driver for JDBC and SQLJ properties define how the connection to a particular data source should be made. Most properties can be set for a DataSource object or for a Connection object.
Page 218
Connection con = java.sql.DriverManager.getConnection(url); Related concepts “How to determine which type of IBM Data Server Driver for JDBC and SQLJ connectivity to use” on page 17 “LOBs in JDBC applications with the IBM Data Server Driver for JDBC and SQLJ” on page 49 “...
Common IBM Data Server Driver for JDBC and SQLJ properties for all supported database products Most of the IBM Data Server Driver for JDBC and SQLJ properties apply to all database products that the driver supports. Unless otherwise noted, all properties are in com.ibm.db2.jcc.DB2BaseDataSource.
Page 220
IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 Database for Linux, UNIX, and Windows and IBM Data Server Driver for JDBC and SQLJ type 4 connectivity. clientRerouteAlternatePortNumber Specifies one or more port numbers for client reroute.
Page 221
If the connection is to a DB2 for z/OS server, the databaseName value is the DB2 location name that is defined during installation. All characters in this value must be uppercase characters. You can determine the location name by executing the following SQL statement on the server: SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1;...
Page 222
Specifies whether cursors that are defined WITH HOLD can be opened under XA connections. downgradeHoldCursorsUnderXa applies to: IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2 for z/OS servers. IBM Data Server Driver for JDBC and SQLJ type 4 connectivity or IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 Database for Linux, UNIX, and Windows servers.
Page 223
This is the default. The effect of the maxRetriesForClientReroute and retryIntervalForClientReroute properties differs depending on whether enableClientAffinitiesList is enabled. This property applies only to IBM Data Server Driver for JDBC and SQLJ type 4 connectivity. enableSeamlessFailover Specifies whether the IBM Data Server Driver for JDBC and SQLJ uses seamless failover for client reroute.
Page 224
IBM Data Server Driver for JDBC and SQLJ. The queryDataSize property applies only to IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2 for z/OS and DB2 Database for Linux, UNIX, and Windows, and to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 Database for Linux, UNIX, and Windows.
Page 225
The port number where the DRDA server is listening for requests. The data type of this property is int. This property is applicable only to IBM Data Server Driver for JDBC and SQLJ type 4 connectivity. progressiveStreaming Specifies whether the JDBC driver uses progressive streaming when progressive streaming is supported on the data source.
Page 226
If maxRetriesForClientReroute or retryIntervalForClientReroute is not set, the IBM Data Server Driver for JDBC and SQLJ performs retries for 10 minutes. If the enableClientAffinitiesList is set to DB2BaseDataSource.NO (2), an attempt to connect to the primary server and alternate servers counts as one retry. The driver waits the number of seconds that is specified by retryIntervalForClientReroute before retrying the connection.
Page 227
ENCRYPTED_USER_AND_PASSWORD_SECURITY and attempts to connect to the server. Any other mismatch in security mechanism support between the requester and the server results in an error. This property is applicable only to IBM Data Server Driver for JDBC and SQLJ type 4 connectivity. sendDataAsIs Specifies that the IBM Data Server Driver for JDBC and SQLJ does not convert input parameter values to the target column data types.
Page 228
Specifies the name of the Java truststore on the client that contains the server certificate for an SSL connection. The IBM Data Server Driver for JDBC and SQLJ uses this option only if the sslConnection property is set to true.
Page 229
If the traceFile property is also specified, the traceDirectory value is not used. traceFile Specifies the name of a file into which the IBM Data Server Driver for JDBC and SQLJ writes trace information. The data type of this property is String.
Page 230
PooledConnection. The data type of this property is int. Possible values are: positive integer Enables the internal statement cache for a PooledConnection, and specifies the number of statements that the IBM Data Server Driver for JDBC and SQLJ keeps open in the cache. ™...
Common IBM Data Server Driver for JDBC and SQLJ properties for DB2 servers Some of the IBM Data Server Driver for JDBC and SQLJ properties apply to DB2 for z/OS and DB2 Database for Linux, UNIX, and Windows only. Unless otherwise noted, all properties are in com.ibm.db2.jcc.DB2BaseDataSource.
Page 232
DB2 for z/OS server. Database administrators can use this property to correlate work on a DB2 for z/OS server to client applications. The data type of this property is String. The maximum length is 12 bytes. If this value is null, the IBM Data Server Driver for JDBC and SQLJ supplies a value of db2jccthread-name.
Page 233
ID for each IBM Data Server Driver for JDBC and SQLJ instance. To choose an instance of the IBM Data Server Driver for JDBC and SQLJ for a connection, you specify a currentPackageSet value that matches the collection ID for one of the IBM Data Server Driver for JDBC and SQLJ instances.
Page 234
The default is com.ibm.db2.jcc.DB2BaseDataSource.ISO. decimalRoundingMode Specifies the rounding mode for decimal floating-point values on DB2 for z/OS Version 9 or later, or DB2 Database for Linux, UNIX, and Windows database servers. Possible values are: com.ibm.db2.jcc.DB2BaseDataSource.ROUND_DOWN (1) Rounds the value towards 0 (truncation). The discarded digits are ignored.
Page 235
For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS, multiple-row fetch is not compatible with progressive streaming. Therefore, if progressive streaming is used for a FETCH operation, multiple-row FETCH is not used.
Page 236
You obtain a value for this property from the client, by invoking the GSSContext.getDelegCred method. GSSContext is part of the IBM Java Generic Security Service (GSS) API. If you set this property, you also need to set the Mechanism and KerberosServerPrincipal properties.
Page 237
DB2 for z/OS Version 9.1 and later supports progressive streaming for LOBs and XML objects. DB2 Database for Linux, UNIX, and Windows Version 9.5 and later, and IBM Informix Dynamic Server (IDS) Version 11.50 and later...
Page 238
SQL AS clause, as input. If the SQL AS clause was not specified, the label is the column name. v The IBM Data Server Driver for JDBC and SQLJ does not use a column label that is assigned by the SQL LABEL ON statement.
Page 239
The value that is returned by ResultSetMetaData.getColumnLabel is the label that is specified in the LABEL ON statement. v ResultSet.findColumn takes the column name as input. These rules conform to the behavior of the IBM Data Server Driver for JDBC and SQLJ before Version 3.50. com.ibm.db2.jcc.DB2BaseDataSource.NOT_SET (0) This is the default behavior.
PooledConnection object. maxStatements applies only to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS, and to IBM Data Server Driver for JDBC and SQLJ type 4 connectivity. Related information...
Specifies whether JDBC SQLException.getMessage or SQLWarning.getMessage calls cause the IBM Data Server Driver for JDBC and SQLJ to invoke a DB2 for z/OS stored procedure that retrieves the message text for the error. The data type of this property is boolean. The default is false, which means that the full message text is not returned to the client.
IBM Data Server Driver for JDBC and SQLJ properties for DB2 Database for Linux, UNIX, and Windows Some of the IBM Data Server Driver for JDBC and SQLJ properties apply only to DB2 Database for Linux, UNIX, and Windows servers.
Page 243
Linux, UNIX, and Windows Version 1 is performed to generate an access plan. Specifies a level of optimization higher than that of DB2 Database for Linux, UNIX, and Windows Version 1, but at significantly less optimization cost than levels 3 and above, especially for very complex queries.
The default is false. This property is applicable only under the following conditions: v The connection is to a DB2 Database for Linux, UNIX, and Windows server that uses the Database Partitioning Feature (DPF). v The partitioning key remains constant throughout a transaction.
Page 245
Specifies the maximum number of bytes to use for INOUT or OUT stored procedure parameters that are registered as Types.CHAR charOutputSize applies only to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS database servers.
Page 246
This value can change during a connection. The data type of this property is String. For a DB2 for z/OS server, the maximum length is 18 bytes. A Java empty string (″″) is valid for this value, but a Java null value is not valid.
Page 247
NULLID.*. planName Specifies a DB2 plan name that is used for the underlying RRSAF CREATE THREAD call when a JDBC or SQLJ connection to a data source is established. planName applies only to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS.
Page 248
CCSID of the DB2 for z/OS database server, or sends the data in UTF-8 encoding for conversion by the database server. sendCharInputsUTF8 applies to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS database servers only. The data type of this property is int.
Specifies the name of the local DB2 for z/OS subsystem to which a connection is established using IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS. The data type of this property is String.
Page 250
SQLWarning to the application if an SQL statement does not use ANSI-standard syntax. You can use the DBANSIWARN IBM Data Server Driver for JDBC and SQLJ property to set the DBANSIWARN IDS property, but you cannot use the DBANSIWARN IBM Data Server Driver for JDBC and SQLJ property to reset the DBANSIWARN IDS property.
Page 251
false The application cannot contain delimited SQL identifiers. Double quotation marks (″) or single quotation marks (’) delimit literal strings. This is the default. true The application can contain delimited SQL identifiers. Delimited SQL identifiers must be enclosed in double quotation marks (″). Single quotation marks (’) delimit literal strings.
Page 252
If this property is not set, no value is sent to the server. The value for the INFORMIXSTACKSIZE environment variable is used. NODEFDAC Specifies whether the database server prevents default table privileges (SELECT, INSERT, UPDATE, and DELETE) from being granted to PUBLIC when a new table is created during the current session, in a database that is not ANSI compliant.
Page 253
You can specify one or more of the following types of statistics with the db2.jcc.dumpPool property: v DUMP_REMOVE_OBJECT (hexadecimal: X’01’, decimal: 1) v DUMP_GET_OBJECT (hexadecimal: X’02’, decimal: 2) v DUMP_WAIT_OBJECT (hexadecimal: X’04’, decimal: 4)
Page 254
dumpPoolStatisticsOnSchedule Specifies how often, in seconds, global transport pool statistics are written to the file that is specified by dumpPoolStatisticsOnScheduleFile. The global transport object pool is used for the connection concentrator and Sysplex workload balancing. The default is -1. -1 means that global transport pool statistics are not written. This property does not have a setXXX or a getXXX method.
IBM Data Server Driver for JDBC and SQLJ configuration properties The IBM Data Server Driver for JDBC and SQLJ configuration properties have driver-wide scope. The following table summarizes the configuration properties and corresponding Connection or DataSource properties, if they exist.
Page 256
Connection or DataSource property. 2. The configuration property setting overrides the Connection or DataSource property. 3. The corresponding Connection or DataSource property is defined only for IBM Informix Dynamic Server. 4. The configuration property applies to DB2 for z/OS.
Page 257
Types.CHAR. Because DESCRIBE information for stored procedure INOUT and OUT parameters is not available at run time, by default, the IBM Data Server Driver for JDBC and SQLJ sets the maximum length of each character INOUT or OUT parameter to 32767.
Page 258
The IBM Data Server Driver for JDBC and SQLJ uses the following values for its rounding mode: v If the data source is DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows, the rounding mode is ROUND_HALF_EVEN for decimal or decimal floating-point values.
Page 259
Server Driver for JDBC and SQLJ returns ’FFFFF’. db2.jcc.defaultSQLState=xxxxx xxxxx is the value that the IBM Data Server Driver for JDBC and SQLJ returns when the SQLSTATE value is null. If xxxxx is longer than five bytes, the driver truncates the value to five bytes. If xxxxx is shorter than five bytes, the driver pads xxxxx on the right with blanks.
Page 260
Indicates that JMX is disabled. This is the default. db2.jcc.lobOutputSize Specifies the number of bytes of storage that the IBM Data Server Driver for JDBC and SQLJ needs to allocate for output LOB values when the driver cannot determine the size of those LOBs. This situation occurs for LOB stored procedure output parameters.
Page 261
Specify this property if you do not bind plans for your SQLJ programs or for the JDBC driver. If you specify this property, do not specify db2.jcc.planName. db2.jcc.pkList applies only to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS. db2.jcc.pkList does not apply to applications that run under CICS or IMS, or to Java stored procedures.
Page 262
Specifies a DB2 for z/OS plan name that is used for the underlying RRSAF CREATE THREAD call when a JDBC or SQLJ connection to a data source is established. Specify this property if you bind plans for your SQLJ programs and for the JDBC driver packages.
Page 263
Specifies whether the IBM Data Server Driver for JDBC and SQLJ converts character input data to the CCSID of the DB2 for z/OS database server, or sends the data in UTF-8 encoding for conversion by the database server. db2.jcc.sendCharInputsUTF8 applies to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS database servers only.
Page 264
Enables the IBM Data Server Driver for JDBC and SQLJ trace for Java driver code, and specifies a directory into which trace information is written. These properties do not apply to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS. When db2.jcc.override.traceDirectory is specified, trace information for multiple connections on the same DataSource is written to multiple files.
Page 265
Specifies the DB2 for z/OS subsystem to which applications make connections with IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS. The db2.jcc.ssid value can be the name of the local DB2 subsystem or a group attachment name. For example: db2.jcc.ssid=DB2A...
Page 266
The db2.jcc.override.traceFile property overrides the traceFile property for a Connection or DataSource object. For example, specifying the following setting for db2.jcc.override.traceFile enables tracing of the IBM Data Server Driver for JDBC and SQLJ Java code to a file named /SYSTEM/tmp/jdbctrace: db2.jcc.override.traceFile=/SYSTEM/tmp/jdbctrace You should set the trace properties under the direction of IBM Software Support.
Page 267
Enables the IBM Data Server Driver for JDBC and SQLJ trace for C/C++ native driver code for IBM Data Server Driver for JDBC and SQLJ type 2 connectivity, and specifies the name on which the trace file names are based. This property is required for collecting trace data for C/C++ native driver code.
IBM Informix JDBC Driver (IDS JDBC Driver) If a method has JDBC 2.0 and JDBC 3.0 forms, the IBM Data Server Driver for JDBC and SQLJ supports all forms. The DB2 JDBC Type 2 Driver for Linux, UNIX and Windows supports only the JDBC 2.0 forms.
Page 269
3. For versions of the IBM Data Server Driver for JDBC and SQLJ before version 3.50, these methods cannot be used if a Blob is passed to a stored procedure as an IN or INOUT parameter, and the methods are used on the Blob in the stored procedure.
Page 270
Table 38. Support for CallableStatement methods IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support Methods inherited from java.sql.Statement Methods inherited from java.sql.PreparedStatement...
Page 271
1. The inherited getParameterMetaData method is not supported if the data source is DB2 for z/OS. 2. This is a JDBC 4.0 method. 3. The following forms of CallableStatement.getXXX methods are not supported if the data source is DB2 for z/OS: getXXX(String parameterName) 4.
Page 272
3. For versions of the IBM Data Server Driver for JDBC and SQLJ before version 3.50, these methods cannot be used if a Clob is passed to a stored procedure as an IN or INOUT parameter, and the methods are used on the Clob in the stored procedure.
Page 273
Notes: 1. This is a JDBC 4.0 method. 2. The DB2 JDBC Type 2 Driver for Linux, UNIX and Windows does not support the JDBC 3.0 forms of this method. 3. This is a JDBC 4.0 method. 4. Under IBM Data Server Driver for JDBC and SQLJ type 4 connectivity, an SQLException is thrown if the timeout parameter value is less than 0.
Page 274
Table 44. Support for DatabaseMetaData methods DB2 JDBC Type 2 Driver IBM Data for Linux, Server Driver UNIX and for JDBC and Windows IDS JDBC JDBC method SQLJ support support Driver support allProceduresAreCallable allTablesAreSelectable dataDefinitionCausesTransactionCommit dataDefinitionIgnoredInTransactions deletesAreDetected doesMaxRowSizeIncludeBlobs getAttributes getBestRowIdentifier...
Page 275
Table 44. Support for DatabaseMetaData methods (continued) DB2 JDBC Type 2 Driver IBM Data for Linux, Server Driver UNIX and for JDBC and Windows IDS JDBC JDBC method SQLJ support support Driver support getMaxCharLiteralLength getMaxColumnNameLength getMaxColumnsInGroupBy getMaxColumnsInIndex getMaxColumnsInOrderBy getMaxColumnsInSelect getMaxColumnsInTable...
Page 276
Table 44. Support for DatabaseMetaData methods (continued) DB2 JDBC Type 2 Driver IBM Data for Linux, Server Driver UNIX and for JDBC and Windows IDS JDBC JDBC method SQLJ support support Driver support getTablePrivileges getTables getTableTypes getTimeDateFunctions getTypeInfo getUDTs getURL...
Page 277
Table 44. Support for DatabaseMetaData methods (continued) DB2 JDBC Type 2 Driver IBM Data for Linux, Server Driver UNIX and for JDBC and Windows IDS JDBC JDBC method SQLJ support support Driver support supportsCatalogsInDataManipulation supportsCatalogsInIndexDefinitions supportsCatalogsInPrivilegeDefinitions supportsCatalogsInProcedureCalls supportsCatalogsInTableDefinitions SupportsColumnAliasing supportsConvert...
Page 278
Table 44. Support for DatabaseMetaData methods (continued) DB2 JDBC Type 2 Driver IBM Data for Linux, Server Driver UNIX and for JDBC and Windows IDS JDBC JDBC method SQLJ support support Driver support supportsPositionedDelete supportsPositionedUpdate supportsResultSetConcurrency supportsResultSetHoldability supportsResultSetType supportsSavepoints supportsSchemasInDataManipulation...
Page 279
2. This method is supported for connections to DB2 Database for Linux, UNIX, and Windows and IDS only. 3. Under the IBM Data Server Driver for JDBC and SQLJ, DB2 data sources and IDS data sources return true for this method. Under the IDS JDBC Driver, IDS data sources return false.
Page 280
Notes: 1. The DB2 JDBC Type 2 Driver does not use this setting. 2. This method is not supported for IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS. ™ Application Programming Guide and Reference for Java...
Page 281
Table 49. Support for ParameterMetaData methods IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support getParameterClassName getParameterCount getParameterMode getParameterType getParameterTypeName getPrecision getScale isNullable isSigned Table 50.
Page 282
Table 51. Support for PreparedStatement methods (continued) IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support setBlob setBoolean setByte setBytes setCharacterStream setClob setDate...
Page 283
Table 51. Support for PreparedStatement methods (continued) IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support Notes: 1. If the value of the length parameter is -1, all of the data from the InputStream or Reader is read and sent to the data source.
Page 284
Table 53. Support for ResultSet methods (continued) IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support getAsciiStream getBigDecimal getBinaryStream getBlob getBoolean getByte getBytes...
Page 285
Table 53. Support for ResultSet methods (continued) IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support moveToCurrentRow moveToInsertRow next previous refreshRow relative rowDeleted...
Page 286
Table 53. Support for ResultSet methods (continued) IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support Notes: 1. getBinaryStream is not supported for CLOB columns.
Page 287
Notes: 1. These methods are JDBC 4.0 methods. 2. These methods are supported for connections to DB2 for z/OS, DB2 for i5/OS, and IDS data sources. Table 56. Support for SQLClientInfoException methods IBM Data Server DB2 JDBC Type 2...
Page 288
Table 57. Support for SQLData methods IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support getSQLTypeName readSQL writeSQL Table 58. Support for SQLDataException methods...
Page 289
Table 61. Support for SQLInput methods IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support readArray readAsciiStream readBigDecimal readBinaryStream readBlob readBoolean readByte readBytes...
Page 290
Table 63. Support for SQLInvalidAuthorizationSpecException methods IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support Methods inherited from java.lang.Exception Methods inherited from java.lang.Throwable Methods inherited from java.lang.Object...
Page 291
Table 66. Support for SQLOutput methods (continued) IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support writeBoolean writeByte writeBytes writeCharacterStream writeClob writeDate writeDouble...
Page 292
Table 68. Support for SQLSyntaxErrorException methods (continued) IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support Note: 1. This is a JDBC 4.0 class.
Page 293
Notes: 1. These are JDBC 4.0 methods. These methods are not supported for connections to IBM Informix Dynamic Server servers. Table 74. Support for Statement methods IBM Data Server DB2 JDBC Type 2 Driver for JDBC and...
Page 294
Table 74. Support for Statement methods (continued) IBM Data Server DB2 JDBC Type 2 Driver for JDBC and Driver for Linux, UNIX IDS JDBC Driver JDBC method SQLJ support and Windows support support getGeneratedKeys getMaxFieldSize getMaxRows getMoreResults getQueryTimeout getResultSet getResultSetConcurrency...
Page 295
Type 2 and type 4 connectivity from a Linux, UNIX, or Windows client to a DB2 Database for Linux, UNIX, and Windows server, Version 8 or later v Type 2 and type 4 connectivity from a Linux, UNIX, or Windows client to a DB2 for z/OS server, Version 9 or later...
Page 296
Notes: 1. This method is supported for IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to a DB2 Database for Linux, UNIX, and Windows server or IBM Data Server Driver for JDBC and SQLJ type 4 connectivity.
“LOBs in JDBC applications with the IBM Data Server Driver for JDBC and SQLJ” on page 49 Related tasks “Learning about a data source using DatabaseMetaData methods” on page 21 “Creating and modifying database objects using the Statement.executeUpdate method” on page 24 “Updating data in tables using the PreparedStatement.executeUpdate method”...
Syntax simple-variable (complex-expression) INOUT Description Indicates that the variable or expression that follows is a host expression. The colon must immediately precede the variable or expression. IN|OUT|INOUT For a host expression that is used as a parameter in a stored procedure call, identifies whether the parameter provides data to the stored procedure (IN), retrieves data from the stored procedure (OUT), or does both (INOUT).
For an iterator, specifies whether changes that are made to the underlying table can be visible to the iterator after it is opened. The value must be INSENSITIVE, SENSITIVE, or ASENSITIVE. The default is ASENSITIVE. For connections to IBM Informix Dynamic Server (IDS), only INSENSITIVE is supported. dynamic...
Page 300
For a connection context, specifies the logical name of a separately-created DataSource object that represents the data source to which the application will connect. This option is available only for the IBM Data Server Driver for JDBC and SQLJ. Usage notes v The value on the left side of a with element must be unique within its with clause.
SQLJ connection-declaration-clause The connection declaration clause declares a connection to a data source in an SQLJ application program. Syntax context Java-class-name Java-modifiers implements-clause with-clause Description Java-modifiers Specifies modifiers that are valid for Java class declarations, such as static, public, private, or protected. Java-class-name Specifies a valid Java identifier.
Page 302
Syntax iterator Java-class-name Java-modifiers implements-clause with-clause positioned-iterator-column-declarations named-iterator-column-declarations positioned-iterator-column declarations: Java-data-type named-iterator-column-declarations: Java-data-type Java-ID Description Java-modifiers Any modifiers that are valid for Java class declarations, such as static, public, private, or protected. Java-class-name Any valid Java identifier. During the program preparation process, SQLJ generates an iterator class whose name is this identifier.
checking during serialized profile customization to succeed, the data types of the columns in the iterator must be compatible with the data types of the columns in the result table. See ″Java, JDBC, and SQL data types″ for a list of compatible data types.
SQLJ context-clause A context clause specifies a connection context, an execution context, or both. You use a connection context to connect to a data source. You use an execution context to monitor and modify SQL statement execution. Syntax connection-context execution-context connection-context , execution context Description connection-context...
Page 305
DROP TABLE DROP TABLESPACE DROP TRIGGER DROP VIEW FETCH GRANT INSERT LOCK TABLE MERGE (does not apply to connections to IBM Informix Dynamic Server) REVOKE ROLLBACK SAVEPOINT SELECT INTO SET CURRENT APPLICATION ENCODING SCHEME SET CURRENT DEBUG MODE SET CURRENT DEGREE...
Description ISOLATION LEVEL Specifies one of the following isolation levels: READ COMMITTED Specifies that the current DB2 isolation level is cursor stability. READ UNCOMMITTED Specifies that the current DB2 isolation level is uncommitted read. REPEATABLE READ Specifies that the current DB2 isolation level is read stability.
Related reference “SQLJ statement-clause” on page 288 SQLJ assignment-clause The assignment clause assigns the result of an SQL operation to a Java variable. Syntax Java-ID = { fullselect order-by-clause optimize-for-clause isolation-clause queryno-clause fetch-first-clause iterator-conversion-clause Description Java-ID Identifies an iterator that was declared previously as an instance of an iterator class.
CAST host-expression Description host-expression Identifies the JDBC ResultSet that is to be converted to an SQLJ iterator. Usage notes v If the iterator to which the JDBC ResultSet is to be converted is a positioned iterator, the number of columns in the ResultSet must match the number of columns in the iterator.
Table 82. Summary of sqlj.runtime classes Class name Purpose AsciiStream A class for handling an input stream whose bytes should be interpreted as ASCII. BinaryStream A class for handling an input stream whose bytes should be interpreted as binary. CharacterStream A class for handling an input stream whose bytes should be interpreted as Character.
Page 310
v Closes any open ConnectedProfile objects v Closes the underlying JDBC Connection object close() is equivalent to close(CLOSE_CONNECTION). close(boolean) Format: public abstract void close (boolean close-connection) throws SQLException Performs the following functions: v Releases all resources that are used by the given connection context object v Closes any open ConnectedProfile objects v Closes the underlying JDBC Connection object, depending on the value of the close-connection parameter...
Page 311
An object that contains a set of driver properties for the connection. Any of the IBM Data Server Driver for JDBC and SQLJ properties can be specified. autocommit Whether autocommit is enabled for the connection. A value of true means that autocommit is enabled.
Page 312
Ctx(Connection) Format: public Ctx(java.sql.Connection JDBC-connection-object) throws SQLException Parameters: JDBC-connection-object A previously created JDBC Connection object. If the constructor call throws an SQLException, the JDBC Connection object remains open. Ctx(ConnectionContext) Format: public Ctx(sqlj.runtime.ConnectionContext SQLJ-connection-context-object) throws SQLException Parameters: SQLJ-connection-context-object A previously created SQLJ ConnectionContext object. The following constructors are defined in a concrete implementation of the ConnectionContext interface that results from translation of the statement #sql context Ctx with (dataSource ="jdbc/TestDS");:...
Page 313
Ctx(ConnectionContext) Format: public Ctx(sqlj.runtime.ConnectionContext SQLJ-connection-context-object) throws SQLException Parameters: SQLJ-connection-context-object A previously created SQLJ ConnectionContext object. Methods The following additional methods are generated in a concrete implementation of the ConnectionContext interface that results from translation of the statement #sql context Ctx;: getDefaultContext Format: public static Ctx getDefaultContext()
sqlj.runtime.ForUpdate interface SQLJ implements the sqlj.runtime.ForUpdate interface in SQLJ programs that contain an iterator declaration clause with implements sqlj.runtime.ForUpdate. An SQLJ program that does positioned UPDATE or DELETE operations (UPDATE...WHERE CURRENT OF or DELETE...WHERE CURRENT OF) must include an iterator declaration clause with implements sqlj.runtime.ForUpdate. Methods getCursorName Format:...
ASENSITIVE A constant that can be returned by the getSensitivity method. It indicates that the iterator is defined as ASENSITIVE. This value is not returned by IBM Informix Dynamic Server. FETCH_FORWARD Format: public static final int FETCH_FORWARD A constant that can be used by the following methods: v Set by sqlj.runtime.Scrollable.setFetchDirection and...
Page 316
Returned by sqlj.runtime.ExecutionContext.getFetchDirection It indicates that the iterator fetches rows in a result table in the backward direction, from last to first. This value is not returned by IBM Informix Dynamic Server. FETCH_UNKNOWN Format: public static final int FETCH_UNKNOWN A constant that can be used by the following methods: v Set by sqlj.runtime.Scrollable.setFetchDirection and...
Page 317
getFetchSize Format: synchronized public int getFetchSize() throws SQLException Returns the number of rows that should be fetched by SQLJ when more rows are needed. The returned value is the value that was set by the setFetchSize method, or 0 if no value was set by setFetchSize. getResultSet Format: public abstract ResultSet getResultSet() throws SQLException...
Parameters: number-of-rows The expected number of rows that SQLJ should fetch for the iterator that is associated with the given execution context. If number-of-rows is less than 0 or greater than the maximum number of rows that can be fetched, an SQLException is thrown. Related reference “sqlj.runtime.NamedIterator interface”...
Page 319
getFetchDirection() Format: public abstract int getFetchDirection() throws SQLException Returns the fetch direction of the iterator. Possible values are: sqlj.runtime.ResultSetIterator.FETCH_FORWARD Rows are processed in a forward direction, from first to last. sqlj.runtime.ResultSetIterator.FETCH_REVERSE Rows are processed in a backward direction, from last to first. sqlj.runtime.ResultSetIterator.FETCH_UNKNOWN The order of processing is not known.
public abstract boolean relative(int n) throws SQLException If n>0, positions the iterator on the row that is n rows after the current row. If n<0, positions the iterator on the row that is n rows before the current row. If n=0, positions the iterator on the current row.
Creates an ASCII java.io.InputStream object with a specified length. Parameters: input-stream The InputStream object that SQLJ interprets as an AsciiStream object. length The length of the InputStream object that SQLJ interprets as an AsciiStream object. Related reference “sqlj.runtime.BinaryStream class” “sqlj.runtime.CharacterStream class” on page 306 “sqlj.runtime.StreamWrapper class”...
Page 322
sqlj.runtime.CharacterStream class The sqlj.runtime.CharacterStream class is for an input stream of character data with a specified length. The sqlj.runtime.CharacterStream class is derived from the java.io.Reader class, and extends the java.io.FilterReader class. SQLJ interprets the bytes in an sqlj.runtime.CharacterStream object are interpreted as Unicode data. A Reader object with Unicode data needs to be passed as a sqlj.runtime.CharacterStream object.
Parameters: length The number of characters that are read from the Reader object. Related reference “sqlj.runtime.AsciiStream class” on page 304 “sqlj.runtime.BinaryStream class” on page 305 “sqlj.runtime.StreamWrapper class” on page 314 “sqlj.runtime.UnicodeStream class” on page 316 sqlj.runtime.ExecutionContext class The sqlj.runtime.ExecutionContext class is defined for execution contexts. An execution context is used to control the execution of SQL statements.
Page 324
public static final int QUERY_COUNT A constant that can be passed to the setBatchLimit method. It indicates that the previous execution produced a result set. UNLIMITED_BATCH Format: public static final int UNLIMITED_BATCH A constant that can be returned from the getUpdateCount method. It indicates that statements should continue to be added to a statement batch, regardless of the batch size.
Page 325
executeQuery Format: public RTResultSet executeQuery ( ) throws SQLException This method is used by code that is generated by the SQLJ translator. It is not intended for direct use by application programs. executeUpdate Format: public int executeUpdate() throws SQLException This method is used by code that is generated by the SQLJ translator. It is not intended for direct use by application programs.
Page 326
synchronized public int getFetchSize() throws SQLException Returns the number of rows that should be fetched by SQLJ when more rows are needed. This value applies only to iterator objects that were generated from the given execution context. The returned value is the value that was set by the setFetchSize method, or 0 if no value was set by setFetchSize.
Page 327
current Indicates what SQLJ does with the currently open result set before it advances to the next result set: java.sql.Statement.CLOSE_CURRENT_RESULT Specifies that the current ResultSet object is closed when the next ResultSet object is returned. java.sql.Statement.KEEP_CURRENT_RESULT Specifies that the current ResultSet object stays open when the next ResultSet object is returned.
Page 328
isBatching Format: public synchronized boolean isBatching() Returns true if batching is enabled for the execution context. Returns false if batching is disabled. registerStatement Format: public RTStatement registerStatement(ConnectionContext connCtx, Object profileKey, int stmtNdx) throws SQLException This method is used by code that is generated by the SQLJ translator. It is not intended for direct use by application programs.
Page 329
ExecutionContext.AUTO_BATCH Indicates that implicit execution occurs when the number of statements in the batch reaches a number that is set by SQLJ. Positive integer The number of statements that are added to the batch before SQLJ executes the batch implicitly. The batch might be executed before this many statements have been added if SQLJ encounters a statement that is batchable but incompatible, or not batchable.
0 means that execution time is unlimited. 0 is the default. For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS database servers, 0 is the only valid value.
Page 331
The sqlj.runtime.AsciiStream, sqlj.runtime.BinaryStream, and sqlj.runtime.UnicodeStream classes extend sqlj.runtime.StreamWrapper. sqlj.runtime.StreamWrapper supports methods for specifying the length of sqlj.runtime.AsciiStream, sqlj.runtime.BinaryStream, and sqlj.runtime.UnicodeStream objects. Constructors StreamWrapper(InputStream) Format: protected StreamWrapper(InputStream input-stream) Creates an sqlj.runtime.StreamWrapper object with an unspecified length. Parameters: input-stream The InputStream object that the sqlj.runtime.StreamWrapper object wraps. StreamWrapper(InputStream, int) Format: protected StreamWrapper(java.io.InputStream input-stream, int length)
“sqlj.runtime.StreamWrapper class” on page 314 IBM Data Server Driver for JDBC and SQLJ extensions to JDBC The IBM Data Server Driver for JDBC and SQLJ provides a set of extensions to the support that is provided by the JDBC specification.
Page 333
((com.ibm.db2.jcc.DB2BaseDataSource) ds).setServerName("sysmvs1.stl.ibm.com"); Table 83 summarizes the IBM Data Server Driver for JDBC and SQLJ-only interfaces. Table 83. Summary of IBM Data Server Driver for JDBC and SQLJ-only interfaces provided by the IBM Data Server Driver for JDBC and SQLJ Interface name...
Table 84. Summary of IBM Data Server Driver for JDBC and SQLJ-only classes provided by the IBM Data Server Driver for JDBC and SQLJ (continued) Class name Applicable data sources Purpose DB2ConnectionPoolDataSource 1, 2, 3 A factory for PooledConnection objects.
DB2BaseDataSource implements the java.sql.Wrapper interface. DB2BaseDataSource properties The following properties are defined only for the IBM Data Server Driver for JDBC and SQLJ. You can set all properties on a DataSource or in the url parameter in a DriverManager.getConnection call.
Page 336
SQLJ type 2 connectivity on DB2 for z/OS only) com.ibm.db2.jcc.DB2BaseDataSource.clientWorkstation ( IBM Data Server Driver for 1 on page 324 String JDBC and SQLJ type 2 connectivity on DB2 for z/OS only) | | | com.ibm.db2.jcc.DB2BaseDataSource.connectNode 2 on page 324 com.ibm.db2.jcc.DB2BaseDataSource.currentDegree...
Page 337
String on page 324 com.ibm.db2.jcc.DB2BaseDataSource.loginTimeout (not supported for IBM Data Server 1 on page 324, 2 Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS) on page 324, 3 on page 324 com.ibm.db2.jcc.DB2BaseDataSource.logWriter 1 on page 324, 2...
Page 338
1 on page 324, 2 on page 324, 3 on page 324 com.ibm.db2.jcc.DB2BaseDataSource.maxRowsetSize ( IBM Data Server Driver for JDBC 1 on page 324 and SQLJ type 2 connectivity on DB2 for z/OS only) com.ibm.db2.jcc.DB2BaseDataSource.maxTransportObjectIdleTime 3 on page 324 com.ibm.db2.jcc.DB2BaseDataSource.maxTransportObjectWaitTime 3 on page 324 com.ibm.db2.jcc.DB2BaseDataSource.maxTransportObjects...
Page 339
324 com.ibm.db2.jcc.DB2BaseDataSource.sqljEnableClassLoaderSpecificProfiles 1 on page 324 boolean com.ibm.db2.jcc.DB2BaseDataSource.ssid ( IBM Data Server Driver for JDBC and SQLJ 1 on page 324 String type 2 connectivity on DB2 for z/OS only) com.ibm.db2.jcc.DB2BaseDataSource.sslConnection ( IBM Data Server Driver for JDBC...
Reference, see the description of javax.naming.Referenceable in the JNDI documentation at: http://java.sun.com/products/jndi/docs.html Related reference “Properties for the IBM Data Server Driver for JDBC and SQLJ” on page 201 DB2ClientRerouteServerList class The com.ibm.db2.jcc.DB2ClientRerouteServerList class implements the java.io.Serializable and javax.naming.Referenceable interfaces. ™...
Page 341
Sets the primary server name for a server. This value is an IP address or a DNS server name. Related concepts “ IBM Data Server Driver for JDBC and SQLJ client reroute support” on page Chapter 7. JDBC and SQLJ reference information...
DB2Connection interface The com.ibm.db2.jcc.DB2Connection interface extends the java.sql.Connection interface. DB2Connection implements the java.sql.Wrapper interface. DB2Connection methods The following methods are defined only for the IBM Data Server Driver for JDBC and SQLJ. alternateWasUsedOnConnect Format: public boolean alternateWasUsedOnConnect() throws java.sql.SQLException Returns true if the driver used alternate server information to obtain the connection.
Page 343
Format: public String getDB2ClientAccountingInformation() throws SQLException Returns accounting information for the current client. Important: getDB2ClientAccountingInformation is deprecated in the JDBC 4.0 implementation of the IBM Data Server Driver for JDBC and SQLJ. Use java.sql.Connection.getClientInfo instead. getDB2ClientApplicationInformation Format: public String getDB2ClientApplicationInformation() throws java.sql.SQLException...
Page 344
Format: public String getDB2CurrentPackagePath() throws java.sql.SQLException Returns the list of DB2 package collections that are searched for JDBC and SQLJ packages. The getDB2CurrentPackagePath method applies only to connections to DB2 database systems. getDB2CurrentPackageSet Format: public String getDB2CurrentPackageSet() throws java.sql.SQLException...
Page 345
Driver for JDBC and SQLJ connection can have a single system monitor. getJccLogWriter Format: public PrintWriter getJccLogWriter() throws java.sql.SQLException Returns the current trace destination for the IBM Data Server Driver for JDBC and SQLJ trace. installDB2JavaStoredProcedure Format: public void DB2Connection.installDB2JavaStoredProcedure( java.io.InputStream jarFile,...
Page 346
IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2 Database for Linux, UNIX, and Windows Version 9.5 or later, and DB2 for z/OS Version 9.1 or later IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS Version 9.1 or later Parameter descriptions: ™...
Page 347
properties New properties for the connection. These properties override any properties that are already defined on the DB2Connection instance. registerDB2XmlSchema Formats: public void registerDB2XmlSchema(String[] sqlIdSchema, String[] sqlIdName, String[] xmlSchemaLocations, InputStream[] xmlSchemaDocuments, int[] xmlSchemaDocumentsLengths, InputStream[] xmlSchemaDocumentsProperties, int[] xmlSchemaDocumentsPropertiesLengths, InputStream xmlSchemaProperties, int xmlSchemaPropertiesLength, boolean isUsedForShredding) throws SQLException public void registerDB2XmlSchema(String[] sqlIdSchema,...
Page 348
Indicates whether there are annotations in the schema that are to be used for XML decomposition. isUsedForShredding is a boolean value. This method does not apply to connections to IBM Informix Dynamic Server data sources. updateDB2XmlSchema Format:...
Page 349
Indicates whether the source XML schema is to be dropped after the target XML schema is updated. dropSourceSchema is a boolean value. false is the default. This method does not apply to connections to IBM Informix Dynamic Server data sources. removeDB2JavaStoredProcedure Format: public void DB2Connection.removeDB2JavaStoredProcedure(...
Page 350
Database for Linux, UNIX, and Windows Version 9.5 or later, and DB2 for z/OS Version 9.1 or later IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS Version 9.1 or later The second of these forms of reuseDB2Connection does not apply to IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS.
Page 351
If userNameRegistry is null, no mapping of user is done. userSecToken The client’s security tokens. This value is traced as part of DB2 for z/OS accounting data. The content of userSecToken is described by the application server and is referred to by the database system as an application server security token.
Page 352
Database for Linux, UNIX, and Windows Version 9.5 or later, and DB2 for z/OS Version 9.1 or later IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS Version 9.1 or later This method is for dirty reuse of a connection. This means that the connection state is not reset when the object is reused from the pool.
Page 353
CLIENT DEBUGINFO is used by the DB2 Unified Debugger. Use the first form to set the entire CLIENT DEBUGINFO string. Use the second form to modify only the session manager and trace information in the CLIENT DEBUGINFO string.
Page 354
That program identifier is an 80-byte string that is used to identify the caller. The DB2 for z/OS server places the string in IFCID 316 trace records along with other statistics, so that you can identify which program is associated with a particular SQL statement.
Page 355
The user ID for the current client.The maximum length depends on the server. For a DB2 Database for Linux, UNIX, and Windows server, the maximum length is 255 bytes. For a DB2 for z/OS server, the maximum length is 16 bytes. A Java empty string (″″) is valid for this parameter value, but a Java null value is not valid.
Page 356
Specifies the collection ID for the connection. When you set this value, you also set the collection ID of the IBM Data Server Driver for JDBC and SQLJ instance that is used for the connection. The setDB2CurrentPackageSet method applies only to connections to DB2 database systems.
DB2ConnectionPoolDataSource properties These properties are defined only for the IBM Data Server Driver for JDBC and SQLJ. ″Properties for the IBM Data Server Driver for JDBC and SQLJ″ for explanations of these properties. These properties have a setXXX method to set the value of the property and a getXXX method to retrieve the value.
Page 358
Database for Linux, UNIX, and Windows Version 9.5 or later, and DB2 for z/OS Version 9.1 or later IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS Version 9.1 or later The following elements are returned in Object[]: v The first element is a trusted DB2PooledConnection instance.
Related concepts Chapter 11, “JDBC and SQLJ connection pooling support,” on page 465 Related reference “Properties for the IBM Data Server Driver for JDBC and SQLJ” on page 201 “DB2PooledConnection class” on page 345 DB2DatabaseMetaData interface The com.ibm.db2.jcc.DB2DatabasemetaData extends the java.sql.DatabaseMetaData interface.
DB2Diagnosable interface The com.ibm.db2.jcc.DB2Diagnosable interface provides a mechanism for getting DB2 diagnostics from an SQLException. DB2Diagnosable methods The following methods are defined only for the IBM Data Server Driver for JDBC and SQLJ. getSqlca Format: public DB2Sqlca getSqlca(); Returns a DB2Sqlca object from a java.sql.Exception that is produced under a IBM Data Server Driver for JDBC and SQLJ.
Trusted connections are supported for: IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2 Database for Linux, UNIX, and Windows Version 9.5 or later, and DB2 for z/OS Version 9.1 or later Chapter 7. JDBC and SQLJ reference information...
Page 362
IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS Version 9.1 or later DB2PooledConnection methods The following methods are defined only for the IBM Data Server Driver for JDBC and SQLJ. getConnection (untrusted or trusted reuse without reauthentication)
Page 363
The client’s security tokens. This value is traced as part of DB2 for z/OS accounting data. The content of userSecToken is described by the application server and is referred to by the data source as an application server security token.
Sysplex workload balancing. DB2PoolMonitor fields The following fields are defined only for the IBM Data Server Driver for JDBC and SQLJ. public static final int TRANSPORT_OBJECT = 1 This values is a parameter for the DB2PoolMonitor.getPoolMonitor method.
Page 365
Retrieves the number of objects that the IBM Data Server Driver for JDBC and SQLJ created since the pool was created. getMonitorVersion Format: public int getMonitorVersion() Retrieves the version of the DB2PoolMonitor class that is shipped with the IBM Data Server Driver for JDBC and SQLJ.
Page 366
Format: public abstract int numberOfRequestsBlockedDataSourceMax() Retrieves the number of requests that the IBM Data Server Driver for JDBC and SQLJ made to the pool that the pool blocked because the pool reached the maximum for the DataSource object. numberOfRequestsBlockedPoolMax...
DB2PreparedStatement interface The com.ibm.db2.jcc.DB2PreparedStatement interface extends the com.ibm.db2.jcc.DB2Statement and java.sql.PreparedStatement interfaces. DB2PreparedStatement methods The following methods are defined only for the IBM Data Server Driver for JDBC and SQLJ. executeDB2QueryBatch Format: public void executeDB2QueryBatch() throws java.sql.SQLException...
DB2ResultSetMetaData methods: The following methods are defined only for the IBM Data Server Driver for JDBC and SQLJ. isDB2ColumnNameDerived Format: public boolean isDB2ColumnNameDerived (int column) throws java.sql.SQLException...
DB2SimpleDataSource implements the java.sql.Wrapper interface. DB2SimpleDataSource properties The following property is defined only for the IBM Data Server Driver for JDBC and SQLJ. See ″Properties for the IBM Data Server Driver for JDBC and SQLJ″ for an explanation of this property. String com.ibm.db2.jcc.DB2SimpleDataSource.password...
“Handling SQL warnings in an SQLJ application” on page 155 DB2Statement interface The com.ibm.db2.jcc.DB2Statement interface extends the java.sql.Statement interface. DB2Statement implements the java.sql.Wrapper interface. DB2Statement methods The following methods are defined only for the IBM Data Server Driver for JDBC and SQLJ. getDB2ClientProgramId Format: public String getDB2ClientProgramId() throws java.sql.SQLException Returns the user-defined client program identifier for the connection, which is stored on the data source.
Page 371
That program identifier is an 80-byte string that is used to identify the caller. The DB2 for z/OS server places the string in IFCID 316 trace records along with other statistics, so that you can identify which program is associated with a particular SQL statement.
Each connection can have one DB2SystemMonitor instance. DB2SystemMonitor fields The following fields are defined only for the IBM Data Server Driver for JDBC and SQLJ. public final static int RESET_TIMES public final static int ACCUMULATE_TIMES These values are arguments for the DB2SystemMonitor.start method.
Page 373
enable Format: public void enable(boolean on) throws java.sql.SQLException Enables the system monitor that is associated with a connection. This method cannot be called during monitoring. All times are reset when enable is invoked. getApplicationTimeMillis Format: public long getApplicationTimeMillis() throws java.sql.SQLException Returns the sum of the application, JDBC driver, network I/O, and database server elapsed times.
Page 374
For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 Database for Linux, UNIX, and Windows, and IBM Data Server Driver for JDBC and...
When the database server is ready to issue the TCP/IP command to return the reply message to the client. For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS: The database server elapsed time interval is the difference, in...
Page 376
DB2TraceManager methods getTraceManager Format: static public DB2TraceManager getTraceManager() throws java.sql.SQLException Gets an instance of the global log writer. setLogWriter Formats: public abstract void setLogWriter(String traceDirectory, String baseTraceFileName, int traceLevel) throws java.sql.SQLException public abstract void setLogWriter(String traceFile, boolean fileAppend, int traceLevel) throws java.sql.SQLException public abstract void setLogWriter(java.io.PrintWriter logWriter, int traceLevel)
Page 377
(X’8000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_T2ZOS (X’10000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_SYSTEM_MONITOR (X’20000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_TRACEPOINTS () (X’40000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL (X’FFFFFFFF’) To specify more than one trace, use one of these techniques: v Use bitwise OR (|) operators with two or more trace values. For...
Page 378
public abstract void unsetLogWriter() throws java.sql.SQLException Disables the global log writer override for future connections. suspendTrace Format: public void suspendTrace() throws java.sql.SQLException Suspends all global, Connection-level, or DataSource-level traces for current and future connections. suspendTrace can be called when the global log writer is enabled or disabled.
Returns true if the global trace records are appended to the trace file. Otherwise, getTraceFileAppend returns false. Related reference “Properties for the IBM Data Server Driver for JDBC and SQLJ” on page 201 DB2TraceManagerMXBean interface The com.ibm.db2.jcc.mx.DB2TraceManagerMXBean interface is the means by which an application makes DB2TraceManager available as an MXBean for the remote trace controller.
Page 380
(X’8000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_T2ZOS (X’10000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_SYSTEM_MONITOR (X’20000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_TRACEPOINTS () (X’40000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL (X’FFFFFFFF’) To specify more than one trace, use one of these techniques: v Use bitwise OR (|) operators with two or more trace values. For...
Page 381
(X’8000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_T2ZOS (X’10000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_SYSTEM_MONITOR (X’20000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_TRACEPOINTS () (X’40000’) v com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL (X’FFFFFFFF’) To specify more than one trace, use one of these techniques: v Use bitwise OR (|) operators with two or more trace values. For...
DB2XADataSource is a factory for XADataSource objects. An object that implements this interface is registered with a naming service that is based on the Java Naming and Directory Interface (JNDI). The com.ibm.db2.jcc.DB2XADataSource class extends the com.ibm.db2.jcc.DB2BaseDataSource class, and implements the javax.sql.XADataSource, java.io.Serializable, and javax.naming.Referenceable interfaces.
Page 383
Database for Linux, UNIX, and Windows Version 9.5 or later, and DB2 for z/OS Version 9.1 or later IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS Version 9.1 or later The following elements are returned in Object[]: v The first element is a DB2TrustedXAConnection instance.
DB2Xml interface The com.ibm.db2.jcc.DB2Xml interface is used for declaring Java objects for use with the DB2 XML data type. DB2Xml methods The following method is defined only for the IBM Data Server Driver for JDBC and SQLJ. closeDB2Xml Format: public void closeDB2Xml() throws SQLException Releases the resources that are associated with a com.ibm.jcc.DB2Xml object.
Page 385
A valid encoding name that is listed in the IANA Charset Registry. The encoding names that are supported by the DB2 server are listed in ″Mappings of CCSIDs to encoding names for serialized XML output data″. Chapter 7. JDBC and SQLJ reference information...
This information is provided only to help you diagnose problems in your applications after you upgrade to the IBM Data Server Driver for JDBC and SQLJ. ™ Application Programming Guide and Reference for Java...
Page 387
Supported methods For a list of methods that the IBM Data Server Driver for JDBC and SQLJ supports, see ″Driver support for JDBC APIs″. Use of progressive streaming by the JDBC drivers For IBM Data Server Driver for JDBC and SQLJ, Version 3.50 and later, use of progressive streaming is the default for LOB retrieval, for connections to DB2 Database for Linux, UNIX, and Windows Version 9.5 and later.
Page 388
ResultSetMetaData.getColumnLabel differs from the default behavior for earlier JDBC drivers. If you need to use IBM Data Server Driver for JDBC and SQLJ version 4.0 or later, but your applications need to return the ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnLabel values that were returned with older JDBC drivers, you can set the useJDBC4ColumnNameAndLabelSemantics Connection and DataSource property to DB2BaseDataSource.NO (2).
Page 389
The IBM Data Server Driver for JDBC and SQLJ does not use existing SQLCODEs or SQLSTATEs for internal errors, as the other drivers do. See ″Error codes issued by the IBM Data Server Driver for JDBC and SQLJ″ and ″SQLSTATEs issued by the IBM Data Server Driver for JDBC and SQLJ″.
Page 390
If the numbers of bytes do not match, the IBM Data Server Driver for JDBC and SQLJ does not throw an exception until the subsequent PreparedStatement.executeUpdate method executes.
Page 391
When character data is transferred between a client and a server, the data must be converted to a form that the receiver can process. For the IBM Data Server Driver for JDBC and SQLJ, character data that is sent from the data source to the client is converted using Java’s built-in character converters.
IBM Data Server Driver for JDBC and SQLJ, you need to understand the differences between those drivers. Supported methods For a list of methods that the IBM Data Server Driver for JDBC and SQLJ supports, see ″Driver support for JDBC APIs″. Use of progressive streaming by the JDBC drivers For IBM Data Server Driver for JDBC and SQLJ, Version 3.50 and later, progressive...
Page 393
ResultSetMetaData.getColumnLabel differs from the default behavior for earlier JDBC drivers. If you need to use IBM Data Server Driver for JDBC and SQLJ version 4.0 or later, but your applications need to return the ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnLabel values that were returned with older JDBC...
Page 394
IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2 for z/OS. Starting with version 3.7 and 3.51: v For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS, the IBM Data Server Driver for JDBC and SQLJ uses only the enableRowsetSupport property to determine whether to use multi-row FETCH for scrollable or forward-only cursors.
Server Driver for JDBC and SQLJ permitted the update or delete operations, but unexpected updates or deletes might occur. Starting with version 3.7 and 3.51 of the IBM Data Server Driver for JDBC and SQLJ, the enableRowsetSupport property enables or disables multi-row FETCH from DB2 for z/OS tables or DB2 Database for Linux, UNIX, and Windows tables.
Page 396
The ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnLabel methods on the query return MYCOL, regardless of the target data source. Example: On a DB2 for z/OS or DB2 for i5/OS data source, a LABEL ON statement is used to define a label for a column: LABEL ON COLUMN MYTABLE.MYCOL IS 'LABELONCOL'...
There are a number of differences between the IBM Data Server Driver for JDBC and SQLJ and the older JDBC drivers. When you move to the IBM Data Server Driver for JDBC and SQLJ, you need to modify your SQLJ programs to account for those differences.
The SQLJ program preparation process for the IBM Data Server Driver for JDBC and SQLJ does not produce DBRMs. Therefore, with the IBM Data Server Driver for JDBC and SQLJ, you can produce DB2 packages only by using the IBM Data Server Driver for JDBC and SQLJ utilities.
Page 399
Table 90. Error codes issued by the IBM Data Server Driver for JDBC and SQLJ Error Code Message text and explanation SQLSTATE +4204 Errors were encountered and tolerated as specified by the 02506 RETURN DATA UNTIL clause. Explanation: Tolerated errors include federated connection, authentication, and authorization errors.
Page 400
Table 90. Error codes issued by the IBM Data Server Driver for JDBC and SQLJ (continued) Error Code Message text and explanation SQLSTATE +4461 text-from-getMessage Explanation: The specified value is invalid of out of range. User response: Call SQLException.getMessage to retrieve specific information about the problem.
Page 401
Table 90. Error codes issued by the IBM Data Server Driver for JDBC and SQLJ (continued) Error Code Message text and explanation SQLSTATE -4203 Error executing function. Server returned rc. : An error occurred on an XA connection during execution of an SQL statement.
Page 402
Table 90. Error codes issued by the IBM Data Server Driver for JDBC and SQLJ (continued) Error Code Message text and explanation SQLSTATE -4225 text-from-getMessage Explanation: An error occurred when data was sent to a server or received from a server.
Page 403
Table 90. Error codes issued by the IBM Data Server Driver for JDBC and SQLJ (continued) Error Code Message text and explanation SQLSTATE -4470 text-from-getMessage Explanation: The requested operation cannot be performed because the target resource is closed. User response: Call SQLException.getMessage to retrieve specific information about the problem.
Table 90. Error codes issued by the IBM Data Server Driver for JDBC and SQLJ (continued) Error Code Message text and explanation SQLSTATE -4497 The application must issue a rollback. The unit of work has already been rolled back in the DB2 server, but other resource managers involved in the unit of work might not have rolled back their changes.
Page 405
Table 91. SQLSTATEs returned by the IBM Data Server Driver for JDBC and SQLJ SQLSTATE class SQLSTATE Description 01xxx Warning 02xxx No data 02501 The cursor position is not valid for a FETCH of the current row. 02506 Tolerable error...
How to find IBM Data Server Driver for JDBC and SQLJ version and environment information To determine the version of the IBM Data Server Driver for JDBC and SQLJ, as well as information about the environment in which the driver is running, run the DB2Jcc utility on the UNIX System Services command line.
Page 407
[jcc] Driver: IBM DB2 JDBC Universal Driver Architecture 3.50.137 [jcc] Compatible JRE versions: { 1.4, 1.5 } [jcc] Target server licensing restrictions: { z/OS: enabled; SQLDS: enabled; iSe ries: enabled; DB2 for Unix/Windows: enabled; Cloudscape: enabled; Informix: ena bled } [jcc] Range checking enabled: true...
To prepare SQLJ programs for execution, you use commands to translate SQLJ source code into Java source code, compile the Java source code, create and customize SQLJ serialized profiles, and bind DB2 packages. sqlj - SQLJ translator The sqlj command translates an SQLJ source file into a Java source file and zero or more SQLJ serialized profiles.
Page 409
generated by the translator and .class files that are generated by the compiler. The default is the directory that contains the SQLJ source files. The translator uses the directory structure of the SQLJ source files when it puts the generated files in directories. For example, suppose that you want the translator to process two files: v file1.sqlj, which is not in a Java package v file2.sqlj, which is in Java package sqlj.test...
Page 410
When you run the SQLJ translator with the -db2optimize option, if your applications use JDBC 3.0 or earlier functions, the IBM Data Server Driver for JDBC and SQLJ file db2jcc.jar must be in the CLASSPATH for compiling the generated Java application.
- SQLJ profile customizer db2sqljcustomize processes an SQLJ profile, which contains embedded SQL statements. By default, db2sqljcustomize produces four DB2 packages: one for each isolation level. db2sqljcustomize augments the profile with DB2-specific information for use at run time. Authorization...
Page 413
USER RELEASE(COMMIT) SQLERROR(NOPACKAGE) VALIDATE(RUN) RELEASE(DEALLOCATE) SQLERROR(CONTINUE) VALIDATE(BIND) Notes: These options can be specified in any order. DB2 Database for Linux, UNIX, and Windows options BLOCKING UNAMBIG DEGREE 1 EXPLAIN NO EXPLSNAP NO BLOCKING ALL DEC 15 DEGREE ANY EXPLAIN YES...
Page 414
-automaticbind or -onlinecheck option is specified as YES or defaults to YES. The variable parts of the -url value are: server The domain name or IP address of the z/OS system on which the DB2 subsystem resides. port The TCP/IP server port number that is assigned to the DB2 subsystem.
Page 415
SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1; If the connection is to a DB2 Database for Linux, UNIX, and Windows server, database is the database name that is defined during installation. If the connection is to an IBM Cloudscape server, the database is the fully-qualified name of the file that contains the database.
Page 416
DB2 for z/OS system, specify DB2 for z/OS options. If you are preparing your program to run on a DB2 Database for Linux, UNIX, and Windows system, specify DB2 Database for Linux, UNIX, and Windows options.
Page 417
128 or fewer bytes. Using the -singlepkgname option is not recommended. Recommendation: If the target data source is DB2 for z/OS, use uppercase characters for the package-name-stem or package-name value. DB2 for z/OS systems that are defined with certain CCSID values cannot tolerate lowercase characters in package names or collection names.
Page 418
Specifies that DB2 for z/OS performs a DESCRIBE operation on stored procedure parameters. -zosDescProcParms applies to programs that are to be run on DB2 for z/OS database servers only. If DESCRIBE information is available, SQLJ has information about the length and precision of INOUT and OUT parameters, so it allocates only the amount of memory that is needed for those parameters.
Page 419
-qualifier parameter, and user-ID is the value of the -user parameter. The DB2 database server tries the schema names in the SQL path from left to right until it finds a match with the name of a stored procedure that exists on that database server.
Page 420
When -genDBRM is specified, -DBRMDir specifies the local directory into which db2sqljcustomize puts the generated DBRM files. The default is the current directory. -DBRMdir applies to programs that are to be run on DB2 for z/OS database servers only. -tracefile file-name Enables tracing and identifies the output file for trace information.
Page 421
SELECT. Customizing multiple serialized profiles together: Multiple serialized profiles can be customized together to create a single DB2 package. If you do this, and if you specify -staticpostioned YES, any positioned UPDATE or DELETE statement that...
Page 422
It is essential that you specify the VERSION option when you perfom this step. If you do not, you overwrite your original packages. When you run the old version of the program, DB2 loads the old versions of the packages. When you run the new version of the program, DB2 loads the new versions of the packages.
“db2sqljbind - SQLJ profile binder” ″BIND and REBIND options″ (DB2 Command Reference) db2sqljbind - SQLJ profile binder db2sqljbind binds DB2 packages for a serialized profile that was previously customized with the db2sqljcustomize command. Authorization The privilege set of the process must include one of the following authorities:...
Page 425
A name for the database server for which the profile is to be customized. If the connection is to a DB2 for z/OS server, database is the DB2 location name that is defined during installation. All characters in this value must be uppercase characters.
Page 426
DB2 for z/OS system, specify DB2 for z/OS options. If you are preparing your program to run on a DB2 Database for Linux, UNIX, and Windows system, specify DB2 Database for Linux, UNIX, and Windows options.
Page 427
-DBRMdir applies to programs that are to be run on DB2 for z/OS database servers only. -tracefile file-name Enables tracing and identifies the output file for trace information. This option should be specified only under the direction of IBM Software Support.
(iterator) for a positioned UPDATE or DELETE statement is in the same package as the positioned UPDATE or DELETE statement. v Fully qualify DB2 table names in positioned UPDATE and positioned DELETE statements. Related tasks “Program preparation for SQLJ programs” on page 183 “Binding SQLJ applications to access multiple database servers”...
Installing the IBM Data Server Driver for JDBC and SQLJ as part of a DB2 installation To use the IBM Data Server Driver for JDBC and SQLJ as a type 2 driver or a type 4 driver, you need to install the driver on your DB2 subsystem.
OS/390 and z/OS Version 7 servers: In z/OS UNIX System Services, run the DB2T4XAIndoubtUtil against each of those servers. 8. If you plan to use LOB locators to access DBCLOB or CLOB columns in DB2 tables on DB2 for z/OS servers: Create tables on the database servers that are needed for fetching data from DBCLOB or CLOB columns using LOB locators.
Modify PATH to include the directory that contains the shell scripts that invoke IBM Data Server Driver for JDBC and SQLJ program preparation and debugging functions. For example, if the IBM Data Server Driver for JDBC and SQLJ is installed in /usr/lpp/db2910_jdbc, modify PATH as follows: export PATH=/usr/lpp/db2910_jdbc/bin:$PATH...
Chapter 9, “Migrating from the JDBC/SQLJ Driver for OS/390 and z/OS to the IBM Data Server Driver for JDBC and SQLJ,” on page 439 “Upgrading the IBM Data Server Driver for JDBC and SQLJ to a new version” on page 434...
Page 433
DB2JccConfiguration.properties. A standard Java resource search is used to find DB2JccConfiguration.properties. The IBM Data Server Driver for JDBC and SQLJ searches for this resource only if you have not set the db2.jcc.propertiesFile Java system property. DB2JccConfiguration.properties can be a stand-alone file, or it can be included in a JAR file.
IBM Data Server Driver for JDBC and SQLJ Before you can use certain functions of the IBM Data Server Driver for JDBC and SQLJ on a DB2 for z/OS subsystem, you need to install a set of stored procedures and create a set of tables.
Page 435
2. Change the startup procedure name to match the procedure name that you specify in the WLM Create an Application Environment menu. 3. Change the DB2SSN value to the subsystem name of your DB2 for z/OS subsystem. 4. Edit the data set names to match your data set names.
Page 436
Start Parameters If the DB2 subsystem in which the stored procedure runs is not in a Sysplex, the DB2SSN value must match the name of that DB2 subsystem. If the same JCL is used for multiple DB2 subsystems, specify DB2SSN=&IWMSSNM.
Jobs for creating IBM DB2 Driver for JDBC and SQLJ stored procedures and tables DB2 provides JCL jobs that include statements that you can use to define the DB2–supplied stored procedures for JDBC, bind the stored procedure packages, and define the SYSIBM.SYSDUMMYU, SYSIBM.SYSDUMMYA, and SYSIBM.SYSDUMMYE tables.
Page 438
-help DB2Binder option descriptions -url Specifies the data source at which the IBM Data Server Driver for JDBC and SQLJ packages are to be bound. The variable parts of the -url value are: server The domain name or IP address of the operating system on which the database server resides.
Page 439
If the value of -action is add or replace, the value of -size is an integer that is used to calculate the number of DB2 packages that the IBM Data Server Driver for JDBC and SQLJ binds. If the value of -size is integer, the total...
Page 440
OPTIMIZATION PROFILE is used. If -optprofile is not specified, and CURRENT OPTIMIZATION PROFILE is not set, no optimization profile is used. -optprofile is valid only for connections to DB2 Database for Linux, UNIX, and Windows database servers. -owner Specifies the authorization ID of the owner of the packages. The default value is set by the database server.
Page 441
Specifies a string that is delimited with quotation marks. The contents of that string are one or more parameter and value pairs that represent options for rebinding a user package. -bindoptions does not apply to IBM Data Server Driver for JDBC and SQLJ packages.
Page 442
This option corresponds to the DYNAMICRULES(INVOKERUN) bind option. When the package is run as or runs under a stored procedure or user-defined function package, the database server processes dynamic SQL statements using invoke behavior. Otherwise, the database server processes dynamic SQL statements using bind behavior.
Page 443
-keepdynamic value is not supported by the target database server. -310 -reopt value is not supported by the target database server. -313 -optprofile value is not supported by the target database server. Chapter 8. Installing the IBM Data Server Driver for JDBC and SQLJ...
UDB for OS/390 and z/OS Version 7 servers If you plan to implement distributed transactions using IBM Data Server Driver for JDBC and SQLJ type 4 connectivity that include DB2 UDB for OS/390 and z/OS Version 7 servers, you need to run the DB2T4XAIndoubtUtil utility against those servers.
Page 445
Specifies the data source at which DB2T4XAIndoubtUtil is to run. The variable parts of the -url value are: jdbc:db2: Indicates that the connection is to a server in the DB2 family. server The domain name or IP address of the database server.
Page 446
Specifies that the DB2T4XAIndoubtUtil utility displays the SQL statements that it executes. -jdbcCollection collection-name|NULLID Specifies the value of the -collection parameter that was used when the IBM Data Server Driver for JDBC and SQLJ packages were bound with the DB2Binder utility. The -jdbcCollection parameter must be specified if the explicitly or implicitly specified value of the -collection parameter was not NULLID.
CREATE UNIQUE INDEX INDBTIDX ON SYSIBM.INDOUBT(indbtXid, uowId); DB2T4XAIndoubtUtil example Run the DB2T4XAIndoubtUtil to allow a DB2 for OS/390 and z/OS Version 7 subsystem that has IP address mvs1, port number 446, and DB2 location name SJCEC1 to participate in XA distributed transactions.
Chapter 9, “Migrating from the JDBC/SQLJ Driver for OS/390 and z/OS to the IBM Data Server Driver for JDBC and SQLJ,” on page 439 “Upgrading the IBM Data Server Driver for JDBC and SQLJ to a new version” on page 434...
Page 449
System.out.println(" Successful close of Connection"); // Handle errors catch(ClassNotFoundException e) System.err.println("Unable to load IBM Data Server Driver " + "for JDBC and SQLJ, " + e); catch(SQLException e) Chapter 8. Installing the IBM Data Server Driver for JDBC and SQLJ...
OS/390 and z/OS Version 7 servers: In z/OS UNIX System Services, run the DB2T4XAIndoubtUtil against each of those servers. 4. If you plan to use LOB locators to access DBCLOB or CLOB columns in DB2 tables on DB2 for z/OS servers: Create tables on the database servers that are needed for fetching data from DBCLOB or CLOB columns using LOB locators.
Application Connectivity to DB2 for z/OS is a DB2 for z/OS feature that allows IBM Data Server Driver for JDBC and SQLJ type 4 connectivity from clients that do not have DB2 for z/OS installed to DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows servers.
Page 452
Application Connectivity to DB2 for z/OS to bind the packages for the IBM Data Server Driver for JDBC and SQLJ at all DB2 for z/OS servers to which you plan to connect. You need to run DB2Binder once for each server.
Jobs for loading the z/OS Application Connectivity to DB2 for z/OS libraries To allocate the HFS or zFS directory structure and use SMP/E to load the z/OS Application Connectivity to DB2 for z/OS libraries, you need to run a set of jobs. Those jobs are: DDAALA Creates the SMP/E consolidate software inventory (CSI) file.
Page 454
If z/OS Application Connectivity to DB2 for z/OS is installed in /usr/lpp/jcct4v3, modify PATH as follows: export PATH=/usr/lpp/jcct4v3/bin:$PATH CLASSPATH z/OS Application Connectivity to DB2 for z/OS contains the following class files: db2jcc.jar Contains all JDBC classes and the SQLJ runtime classes for IBM Data Server Driver for JDBC and SQLJ type 4 connectivity.
Chapter 9. Migrating from the JDBC/SQLJ Driver for OS/390 and z/OS to the IBM Data Server Driver for JDBC and SQLJ You need to migrate to the IBM Data Server Driver for JDBC and SQLJ before you migrate to DB2 Version 9.1 for z/OS.
Page 456
OS/390 and z/OS Version 7 servers: In z/OS UNIX System Services, run the DB2T4XAIndoubtUtil against each of those servers. 10. If you plan to use LOB locators to access DBCLOB or CLOB columns in DB2 tables on DB2 for z/OS servers: Create tables on the database servers that are needed for fetching data from DBCLOB or CLOB columns using LOB locators.
Page 457
JDBC/SQLJ Driver for OS/390 and z/OS. Information that is provided by the JDBC/SQLJ Driver for OS/390 Chapter 9. Migrating from the JDBC/SQLJ Driver for OS/390 and z/OS to the IBM Data Server Driver for JDBC and SQLJ...
All of the JDBC/SQLJ Driver for OS/390 and z/OS DataSource properties are defined for the IBM Data Server Driver for JDBC and SQLJ, so you do not need to modify those properties in your applications when you migrate to the IBM Data Server Driver for JDBC and SQLJ.
Page 459
Property values are the same in the JDBC/SQLJ Driver for OS/390 and z/OS and the IBM Data Server Driver for JDBC and SQLJ. Chapter 9. Migrating from the JDBC/SQLJ Driver for OS/390 and z/OS to the IBM Data Server Driver for JDBC and SQLJ...
Page 460
Table 96. JDBC/SQLJ Driver for OS/390 and z/OS properties and their IBM Data Server Driver for JDBC and SQLJ equivalents (continued) JDBC/SQLJ Driver for OS/390 and z/OS IBM Data Server Driver for JDBC property and SQLJ equivalent Notes db2.sp.lob.output.parm.size db2.jcc.lobOutputSize...
2. Run the db2sqljupgrade utility. For example: db2sqljupgrade -collection SQLJ01 Sample02_SJProfile0.ser 3. Set the db2.jcc.pkList or db2.jcc.planName configuration property. Chapter 9. Migrating from the JDBC/SQLJ Driver for OS/390 and z/OS to the IBM Data Server Driver for JDBC and SQLJ...
JDBC/SQLJ Driver for OS/390 and z/OS serialized profile. This collection ID is stored in the converted serialized profile and is used as the qualifier for the DB2 packages for the application. The packages were created using the DB2 BIND command from DBRMs that were created when the db2profc command was run to create the serialized profile.
The following table lists the security mechanisms that the IBM Data Server Driver for JDBC and SQLJ supports, and the data sources that support those security mechanisms. Table 97. Database server support for IBM Data Server Driver for JDBC and SQLJ security mechanisms | | | Security mechanism...
ENCRYPTED_USER_AND_PASSWORD_SECURITY and attempts to connect to the server. Any other mismatch in security mechanism support between the requester and the server results in an error. Table 98. Security mechanisms supported by the IBM Data Server Driver for JDBC and SQLJ Security mechanism securityMechanism property value User ID and password DB2BaseDataSource.CLEAR_TEXT_PASSWORD_SECURITY...
Page 465
// Set driver type ds.setDatabaseName("san_jose"); // Set location ds.setServerName("mvs1.sj.ibm.com"); // Set server name ds.setPortNumber(5021); // Set port number ds.setUser("dbadm"); // Set user ID ds.setPassword("dbadm"); // Set password ds.setSecurityMechanism( Chapter 10. Security under the IBM Data Server Driver for JDBC and SQLJ...
// Set security mechanism to // user ID and password IBM Data Server Driver for JDBC and SQLJ type 2 connectivity with no user ID or password: For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity, if...
The IBM Data Server Driver for JDBC and SQLJ supports 56-bit DES (weak) encryption or 256-bit AES (strong) encryption. AES encryption is available with IBM Data Server Driver for JDBC and SQLJ type 4 connectivity only. You set the encryptionAlgorithm driver property to choose between 56-bit DES encryption (encryptionAlgorithm value of 1) and 256-bit AES encryption (encryptionAlgorithm value of 2).
Page 468
ENCRYPTED_USER_AND_DATA_SECURITY is valid for connections to DB2 for z/OS servers only, and only for DES encryption (encryptionAlgorithm value of 1). DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows database servers encrypt the following data when you specify encryption of security-sensitive data:...
Data Server Driver for JDBC and SQLJ” on page 11 “Creating and deploying DataSource objects” on page 19 Related reference “Properties for the IBM Data Server Driver for JDBC and SQLJ” on page 201 Kerberos security under the IBM Data Server Driver for JDBC and SQLJ JDBC support for Kerberos security is available for IBM Data Server Driver for JDBC and SQLJ type 4 connectivity only.
Page 470
DataSource.setKerberosServerPrincipal and DataSource.setSecurityMechanism methods after you create the DataSource object. For example: import java.sql.*; // JDBC base import com.ibm.db2.jcc.*; // IBM Data Server Driver for JDBC // and SQLJ implementation of JDBC com.ibm.db2.jcc.DB2SimpleDataSource db2ds = new com.ibm.db2.jcc.DB2SimpleDataSource(); // Create the DataSource object db2ds.setDriverType(4);...
Page 471
// IBM Data Server Driver for JDBC // and SQLJ implementation of JDBC Properties properties = new Properties(); // Create a Properties object properties.put("kerberosServerPrincipal", “sample/srvlsj.ibm.com@SRVLSJ.SJ.IBM.COM"); // Set the Kerberos server properties.put("gssCredential",delegatedCredential); Chapter 10. Security under the IBM Data Server Driver for JDBC and SQLJ...
Database for Linux, UNIX, and Windows Version 9.5 or later, and DB2 for z/OS Version 9.1 or later IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS Version 9.1 or later A three-tiered application model consists of a database server, a middleware server such as WebSphere Application Server, and end users.
Page 473
A trusted context is an object that the database administrator defines that contains a system authorization ID and a set of trust attributes. Currently, for DB2 database servers, a database connection is the only type of context that is supported. The trust attributes identify a set of characteristics of a connection that are required for the connection to be considered a trusted connection.
You can use SSL support in your Java applications if you use IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2 for z/OS Version 7 or later, to DB2 Database for Linux, UNIX, and Windows Version 9.1, Fix Pack 2 or later, or to IBM Informix Dynamic Server (IDS) Version 11.50 or later.
“Creating and deploying DataSource objects” on page 19 Related reference “Properties for the IBM Data Server Driver for JDBC and SQLJ” on page 201 ″Configuring the DB2 server for SSL″ (DB2 Administration Guide) Configuring connections under the IBM Data Server Driver for...
Page 476
IBM SDK for Java contains an entry for entries for IBMJCE. v For later versions of the IBM SDK for Java, ensure that entries for the IBMJSSE2Provider and the IBMJCE provider are in the java.security file. The java.security file that is shipped with the IBM SDK for Java contains entries for those providers.
Page 477
3. If you plan to use the IBM Data Server Driver for JDBC and SQLJ in FIPS-compliant mode, you need to set the com.ibm.jsse2.JSSEFIPS Java system property: com.ibm.jsse2.JSSEFIPS=true Restriction: Non-FIPS-mode JSSE applications cannot run in a JVM that is in FIPS mode.
2. On the customization-only system, define all the tables and views that are accessed by the SQLJ applications. The table or view definitions must be the same as the definitions on the DB2 subsystem where the application will be bound and will run (the bind-and-run system). Executing the DESCRIBE statement on the tables or views must give the same results on the customization-only system and the bind-and-run system.
Page 479
SELECT privilege only on tables and views with a qualifier that matches the value of the -qualifier parameter. Related reference “db2sqljcustomize - SQLJ profile customizer” on page 395 Chapter 10. Security under the IBM Data Server Driver for JDBC and SQLJ...
Page 480
™ Application Programming Guide and Reference for Java...
Without connection pooling, each java.sql.Connection object represents a physical connection to the data source. When the application establishes a connection to a data source, DB2 creates a new physical connection to the data source. When the application calls the java.sql.Connection.close method, DB2 terminates the physical connection to the data source.
Page 482
“DB2ConnectionPoolDataSource class” on page 341 “DB2PooledConnection class” on page 345 ™ Application Programming Guide and Reference for Java...
Chapter 12. IBM Data Server Driver for JDBC and SQLJ type 4 connectivity JDBC and SQLJ distributed transaction support The IBM Data Server Driver for JDBC and SQLJ in the z/OS environment supports distributed transaction management when you use IBM Data Server Driver for JDBC and SQLJ type 4 connectivity.
Related concepts Chapter 13, “JDBC and SQLJ global transaction support,” on page 473 Related reference “DB2T4XAIndoubtUtil for distributed transactions with DB2 UDB for OS/390 and z/OS Version 7 servers” on page 428 Example of a distributed transaction that uses JTA methods...
Page 485
* Note that javax.sql.XADataSource is used instead of a specific * driver implementation such as com.ibm.db2.jcc.DB2XADataSource. xaDS1 = (javax.sql.XADataSource)context.lookup("checkingAccounts"); xaDS2 = (javax.sql.XADataSource)context.lookup("savingsAccounts"); Chapter 12. IBM Data Server Driver for JDBC and SQLJ type 4 connectivity JDBC and SQLJ distributed transaction support...
Page 486
= xaconn1.getXAResource(); xares2 = xaconn2.getXAResource(); // Create the Xid object for this distributed transaction. // This example uses the com.ibm.db2.jcc.DB2Xid implementation // of the Xid interface. This Xid can be used with any JDBC driver // that supports JTA.
Page 487
(java.sql.SQLException sqe) System.out.println("SQLException caught: " + sqe.getMessage()); sqe.printStackTrace(); catch (javax.transaction.xa.XAException xae) System.out.println("XA error is " + xae.getMessage()); xae.printStackTrace(); catch (javax.naming.NamingException nme) Chapter 12. IBM Data Server Driver for JDBC and SQLJ type 4 connectivity JDBC and SQLJ distributed transaction support...
Page 488
System.out.println(" Naming Exception: " + nme.getMessage()); Recommendation: For better performance, complete a distributed transaction before you start another distributed or local transaction. Related reference “DB2XADataSource class” on page 366 ™ Application Programming Guide and Reference for Java...
SQLJ distributed transaction support. However, JDBC and SQLJ distributed transaction support is available with IBM Data Server Driver for JDBC and SQLJ type 4 connectivity on DB2 for z/OS or DB2 Database for Linux, UNIX, and Windows. You can use global transactions in JDBC or SQLJ applications. Global transactions are supported for connections that are established using the DriverManager or the DataSource interface.
Page 490
Figure 61. Example of a global transaction in a multi-threaded environment Related concepts Chapter 12, “IBM Data Server Driver for JDBC and SQLJ type 4 connectivity JDBC and SQLJ distributed transaction support,” on page 467 ™ Application Programming Guide and Reference for Java...
DB2 Connect. The IBM Data Server Driver for JDBC and SQLJ connection concentrator function can reduce the resources that DB2 for z/OS or IBM Informix Dynamic Server data sources require to support large numbers of client applications. The IBM Data...
Server requirements: v WLM for z/OS v DB2 UDB for OS/390 and z/OS Version 7 or later, set up for data sharing The default values for special registers in all members of the data sharing group must be the same. The reason for this is that when the IBM Data Server Driver for JDBC and SQLJ balances the loads on each member of the data sharing group, it moves the user’s connection from one member to another.
WebSphere Application Server IBM Data Server Driver for JDBC and SQLJ classpath. 3. Set IBM Data Server Driver for JDBC and SQLJ data source properties to enable the connection concentrator or workload balancing: In the WebSphere Application Server administrative console, set the following...
Page 494
The number of physical connections available v The desired ratio of connection objects to transport objects 1. Verify that the IBM Data Server Driver for JDBC and SQLJ is at the correct level to support workload balancing by following these steps: a.
Table 101. Example of data source property settings for IBM Data Server Driver for JDBC and SQLJ connection concentrator and workload balancing for IBM Informix Dynamic Server Property Setting enableSysplexWLB true maxTransportObjects 4. Restart WebSphere Application Server. Techniques for monitoring IBM Data Server Driver for JDBC and SQLJ...
Page 496
The number of objects that were reused from the pool. The number of objects that the IBM Data Server Driver for JDBC and SQLJ created since the pool was created. aooc The number of objects that exceeded the idle time that was specified by db2.jcc.maxTransportObjectIdleTime and were deleted from the pool.
Page 497
“Example of enabling the IBM Data Server Driver for JDBC and SQLJ connection concentrator for DB2 for z/OS servers” on page 476 Chapter 14. JDBC connection concentrator and workload balancing...
Page 498
™ Application Programming Guide and Reference for Java...
Collecting JDBC trace data Use one of the following procedures to start the trace: Procedure 1: For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity, the recommended method is to start the trace by setting the db2.jcc.override.traceFile property and the db2.jcc.t2zosTraceFile property in the IBM Data Server Driver for...
Page 500
JDBC trace″. Trace example program: For a complete example of a program for tracing under the IBM Data Server Driver for JDBC and SQLJ, see ″Example of a trace program under the IBM Data Server Driver for JDBC and SQLJ″.
Formatting information about an SQLJ customized serialized profile The db2sqljprint utility formats information about each SQLJ clause in a serialized profile that is customized for the IBM Data Server Driver for JDBC and SQLJ. Run the db2sqljprint utility on the customized serialized profile for the connection in which the error occurs.
The following example shows such a class. The example uses IBM Data Server Driver for JDBC and SQLJ type 4 connectivity. Figure 62. Example of tracing under the IBM Data Server Driver for JDBC and SQLJ public class TraceExample public static void main(String[] args) sampleConnectUsingSimpleDataSource();...
Page 503
Deadlocks could " + "occur if the connection is not closed."); com.ibm.db2.jcc.DB2ExceptionFormatter.printTrace(e, printWriter, "[TraceExample]"); catch(java.lang.Throwable e) { printWriter.println("[TraceExample] Throwable caught " + "while trying to close the connection"); Chapter 15. Problem diagnosis with the IBM Data Server Driver for JDBC and SQLJ...
Page 504
{ Class.forName("com.ibm.db2.jcc.DB2Driver"); catch(ClassNotFoundException e) { printWriter.println("[TraceExample] " + "IBM Data Server Driver for JDBC and SQLJ type 4 connectivity " + "is not in the application classpath. Unable to load driver."); printWriter.flush(); return; // This URL describes the target data source for Type 4 connectivity.
Page 505
= c.createStatement(); s2.executeUpdate("insert into sampleTable(sampleColumn) values(1)"); s2.close(); c.close(); catch(java.sql.SQLException e) { com.ibm.db2.jcc.DB2ExceptionFormatter.printTrace(e, printWriter, "[TraceExample]"); finally { cleanup(c, printWriter); printWriter.flush(); Related reference “DB2ExceptionFormatter class” on page 344 Chapter 15. Problem diagnosis with the IBM Data Server Driver for JDBC and SQLJ...
Page 506
™ Application Programming Guide and Reference for Java...
1. Enable tracing of C/C++ native driver code by setting a value for the db2.jcc.t2zosTraceFile global configuration property. That value is the name of the file to which the IBM Data Server Driver for JDBC and SQLJ writes the trace data.
Page 508
“Customization of IBM Data Server Driver for JDBC and SQLJ configuration properties” on page 416 Related tasks Chapter 16, “Tracing IBM Data Server Driver for JDBC and SQLJ C/C++ native driver code,” on page 491 ™ Application Programming Guide and Reference for Java...
Chapter 17. System monitoring for the IBM Data Server Driver for JDBC and SQLJ To assist you in monitoring the performance of your applications with the IBM Data Server Driver for JDBC and SQLJ, the driver provides two methods to collect information for a connection.
Page 510
// Load the IBM Data Server Driver for JDBC and SQLJ Class.forName("com.ibm.db2.jcc.DB2Driver"); System.out.println("**** Loaded the JDBC driver"); // Create the connection using the IBM Data Server Driver for JDBC and SQLJ Connection conn = DriverManager.getConnection (url,user,password); // Commit changes manually conn.setAutoCommit(false);...
Page 511
[jcc][SystemMonitor:start] [jcc][SystemMonitor:stop] core: 565.67ms | network: 211.695ms | server: 207.771ms Related reference “DB2SystemMonitor interface” on page 356 Chapter 17. System monitoring for the IBM Data Server Driver for JDBC and SQLJ...
Page 512
™ Application Programming Guide and Reference for Java...
, and many DB2 and IMS Tools products. The majority of the DB2 for z/OS information in this information center is also available in the books that are identified in the following table. You can access these books at the DB2 for z/OS library Web site (http://www.ibm.com/software/data/db2/zos/library.html) or at the IBM Publications Center (http://www.elink.ibmlink.ibm.com/public/...
Page 514
SC18-9858 Note: 1. DB2 Version 9.1 for z/OS Diagnosis Guide and Reference is available in PDF and BookManager formats on the DB2 Version 9.1 for z/OS Licensed Collection kit, LK3T-7195. You can order this License Collection kit on the IBM Publications Center site (http://www.elink.ibmlink.ibm.com/public/applications/publications/cgibin/pbi.cgi).
Page 515
This resource is for DB2 Connect 9. DB2 Database for Linux, Information center: http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp UNIX, and Windows This resource is for DB2 9 for Linux, UNIX, and Windows. DB2 Query Management Information center: http://publib.boulder.ibm.com/infocenter/imzic Facility DB2 Server for VSE & VM One of the following locations: v For VSE: http://www.ibm.com/support/docview.wss?rs=66&uid=swg27003758...
Page 516
Tivoli OMEGAMONXE for Information center: http://publib.boulder.ibm.com/infocenter/tivihelp/v15r1/ DB2 Performance Expert index.jsp?topic=/com.ibm.ko2pe.doc/ko2welcome.htm on z/OS In earlier releases, this product was called DB2 Performance Expert for z/OS. WebSphere Application Information center: http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp Server WebSphere Message Broker Information center: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/ with Rules and Formatter index.jsp...
Page 517
RMF v z/OS Security Server v z/OS UNIX System Services z/OS XL C/C++ http://www.ibm.com/software/awdtools/czos/library/ The following information resources from IBM are not necessarily specific to a single product: v The DB2 for z/OS Information Roadmap; available at: http://www.ibm.com/ software/data/db2/zos/roadmap.html ®...
Page 518
– A collection of glossaries of IBM terms in multiple languages is available on the IBM Terminology Web site at: http://www.ibm.com/software/ globalization/terminology/index.jsp v National Language Support information; available at the IBM Publications Center at: http://www.elink.ibmlink.ibm.com/public/applications/publications/ cgibin/pbi.cgi v SQL Reference for Cross-Platform Development; available at the following ®...
Web: www.ibm.com/software/db2zos On the DB2 home page, you can find links to a wide variety of information resources about DB2. You can read news items that keep you informed about the latest enhancements to the product. Product announcements, press releases, fact sheets, and technical articles help you plan and implement your database management strategy.
Page 520
You can find class information, by country, at the IBM Learning Services Web site: www.ibm.com/services/learning IBM also offers classes at your location, at a time that suits your needs. IBM can customize courses to meet your exact requirements. For more information, including the current local schedule, contact your IBM representative.
Page 521
Be prepared to give your customer number, the product number, and either the feature codes or order numbers that you want. How to obtain DB2 information...
Page 522
™ Application Programming Guide and Reference for Java...
Instead, they point directly to the section that holds the information. If you are new to DB2 for z/OS, Introduction to DB2 for z/OS provides a comprehensive introduction to DB2 Version 9.1 for z/OS. Topics included in this book explain the basic concepts that are associated with relational database management systems in general, and with DB2 for z/OS in particular.
Page 524
DB2 Performance Monitoring and Tuning Guide explains how to monitor the performance of the DB2 system and its parts. It also lists things that can be done to make some parts run faster. If you will be using the RACF access control module for DB2 authorization checking, you will need DB2 RACF Access Control Module Guide.
Page 525
DB2 Command Reference, which explains how to run commands If you will be using data sharing, you need DB2 Data Sharing: Planning and Administration, which describes how to plan for and implement data sharing. Additional information about system and database administration can be found in DB2 Messages and DB2 Codes, which list messages and codes issued by DB2, with explanations and suggested responses.
Page 526
™ Application Programming Guide and Reference for Java...
IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you. Licensees of this program who wish to have information about it for the purpose of enabling: (i) the exchange of information between independently created...
™ occurrence in this information with the appropriate symbol ( ), indicating trademarks that were owned by IBM at the time this information was published. A complete and current list of IBM trademarks is available on the Web at http://www.ibm.com/legal/copytrade.shtml...
Page 530
™ Application Programming Guide and Reference for Java...
APPL A VTAM network definition statement AFTER trigger that is used to define DB2 to VTAM as an A trigger that is specified to be activated application program that uses SNA LU after a defined trigger event (an insert, 6.2 protocols.
Page 532
CREATE TABLE statement and that holds A string that can be verified for persistent data. Contrast with clone table, connection to DB2 and to which a set of materialized query table, result table, privileges is allowed. An authorization ID temporary table, and transition table.
Page 533
CREATE TABLE statement. Contrast with reordered row format. block fetch A capability in which DB2 can retrieve, or basic sequential access method (BSAM) fetch, a large set of rows together. Using An access method for storing or retrieving...
Page 534
A defined set of characters. catalog character string In DB2, a collection of tables that contains A sequence of bytes that represent bit descriptions of objects such as tables, data, single-byte characters, or a mixture views, and indexes.
Page 535
CICS environment to execute DB2 statements. See compatibility mode*. claim A notification to DB2 that an object is C++ member being accessed. Claims prevent drains A data object or function in a structure, from occurring until the claim is released, union, or class.
Page 536
16-MB line. cold start communications database (CDB) A process by which DB2 restarts without A set of tables in the DB2 catalog that are processing any log records. Contrast with used to establish conversations with warm start. remote database management systems.
Page 537
A process that occurs when the length of a converted string is smaller than that of conditional restart the source string. For example, this A DB2 restart that is directed by a process occurs when an EBCDIC user-defined conditional restart control mixed-data string that contains DBCS record (CRCR).
Page 538
TEMPORARY TABLE. Information about A relationship between the value of one created temporary tables is stored in the column and the value of another column. DB2 catalog and can be shared across application processes. Contrast with correlated subquery declared temporary table. See also A subquery (part of a WHERE or temporary table.
Page 539
An internal representation of a DB2 contains the data for an object. database definition, which reflects the data definition that is in the DB2 catalog. data sharing The objects that are defined in a database A function of DB2 for z/OS that enables...
Page 540
The database manager structure that ODBC driver that supports the ODBC describes an application’s connection, APIs. In the case of DB2 for z/OS, the traces its progress, processes resource data sources are always relational functions, and delimits its accessibility to database managers.
Page 541
See also update hole. dependent table. delete rule deterministic function The rule that tells DB2 what to do to a A user-defined function whose result is dependent row when a parent row is dependent on the values of the input deleted.
Page 542
(DDF) double-precision floating point number A set of DB2 components through which A 64-bit approximate representation of a DB2 communicates with another real number. relational database management system. DPSI See data-partitioned secondary index. Distributed Relational Database Architecture...
Page 543
(ENFM*) enumerated list A transitional stage of the A set of DB2 objects that are defined with version-to-version migration process that a LISTDEF utility control statement in applies to a DB2 subsystem or data which pattern-matching characters (*, %;, sharing group that was in new-function _, or ?) are not used.
Page 544
A user-written (or IBM-provided default) database server. The association of the program that receives control from DB2 to function with the external code perform specific functions. Exit routines application is specified by the EXTERNAL run as extensions of DB2.
Page 545
A direct physical access path to data, application is running. which is provided by an index, hash, or link; a fan set is the means by which DB2 foreign key supports the ordering of data. A column or set of columns in a...
Page 546
A lock that provides concurrency control function package within and among DB2 subsystems. The A package that results from binding the scope of the lock is across all DB2 DBRM for a function program. subsystems of a data sharing group. function package owner...
Page 547
See generalized trace facility. An application program that is written in handle a host language and that contains In DB2 ODBC, a variable that refers to a embedded SQL statements. data structure and associated resources. host structure See also statement handle, connection In an application program, a structure handle, and environment handle.
Page 548
IMS to DB2 and to coordinate A status of a unit of recovery. If DB2 fails resource commitment. after it has finished its phase 1 commit in-abort processing and before it has started phase A status of a unit of recovery.
Page 549
A status of a unit of recovery. If DB2 fails view to the underlying tables of the view. before its unit of recovery completes Contrast with BEFORE trigger and phase 1 of the commit process, it merely AFTER trigger.
Page 550
A file format that is used for aggregating message. many files into a single file. latch A DB2 mechanism for controlling JDBC A Sun Microsystems database application concurrent events or the use of system programming interface (API) for Java that resources.
Page 551
The unique relational DBMS to which the link-edit user or application program is directly The action of creating a loadable connected (in the case of DB2, by one of computer program using a linkage editor. the DB2 attachment facilities). list...
Page 552
The amount of data that is controlled by a inconsistent. DB2 lock on table data; the value can be a logical unit (LU) row, a page, a LOB, a partition, a table, or An access point through which an a table space.
Page 553
The process of converting a subsystem native representation that is stored in the with a previous release of DB2 to an database directory, as is done with other updated or current release. In this SQL statements.
Page 554
An entity is normalized if it meets a stage, all new functions of the new set of constraints for a particular normal version are available for use. A DB2 data form (first normal form, second normal sharing group cannot coexist with form, and so on).
Page 555
An object containing a set of SQL parallel I/O processing statements that have been statically A form of I/O processing in which DB2 bound and that is available for initiates multiple concurrent requests for a processing. A package is sometimes also single user query and performs I/O called an application package.
Page 556
In Sysplex query parallelism, the DB2 A table space that contains a parent table. subsystem from which the parallel query A table space containing a dependent of originates. that table is a dependent table space.
Page 557
(P-lock) module (DBRM) that is input to the bind A type of lock that DB2 acquires to process. provide consistency of data that is cached predicate in different DB2 subsystems. Physical...
Page 558
I/O including the PUBLIC authorization ID, requests within a single query. the set of all privileges that are recorded for that ID in the DB2 catalog. queued sequential access method (QSAM) An extended version of the basic process sequential access method (BSAM).
Page 559
The rebind recorded information is used for recovery The creation of a new application plan for in the event of a failure during DB2 an application program that has been execution. bound previously. If, for example, you...
Page 560
The process of returning to a current last table. release of DB2 following a fallback to a previous release. This procedure referential integrity constitutes another migration process. The state of a database in which all values of all foreign keys are valid.
Page 561
Beginning in CICS Transaction Server result set locator Version 1.3, resources are defined by A 4-byte value that DB2 uses to uniquely using resource definition online instead of identify a query result set that a stored the resource control table. See also procedure returns.
Page 562
(ROWID) scale A value that uniquely identifies a row. of the decimal point (called the precision This value is stored with the row and in the C language). The DB2 information never changes. uses the SQL definition. row lock schema A lock on a single row of data.
Page 563
A secondary A non-DB2 data set whose records are index can be partitioned or organized on the basis of their successive nonpartitioned. See also data-partitioned...
Page 564
The target of a request from a remote process by an attachment facility to requester. In the DB2 environment, the enable DB2 to verify that it is authorized server function is provided by the to use DB2 resources. distributed data facility, which is used to simple page set access DB2 data from remote applications.
Page 565
SQL expression that evaluates to a single value. The SQL user-defined special register function can return the result of an A storage area that DB2 defines for an expression. See also built-in function, application process to use for storing external function, and sourced function.
Page 566
The SQL string delimiter storage group is the apostrophe (’), except in COBOL A set of storage objects on which DB2 for applications, where the user assigns the z/OS data can be stored. A storage object symbol, which is either an apostrophe or can have an SMS data class, a a double quotation mark (″).
Page 567
A dump that is issued when a z/OS or a DB2 functional recovery routine detects structure owner an error. In relation to group buffer pools, the DB2 member that is responsible for the sync point following activities: See commit point.
Page 568
A page set that is used to store the A work request that DB2 creates such as records in one or more tables. See also prefetch processing, deferred writes, and partitioned table space, segmented table service tasks.
Page 569
Installation of old values or the set of new values. specifications are set to determine both the amount of time DB2 is to wait for tree structure IRLM services after starting, and the A data structure that represents entities in...
Page 570
A database security object that enables the WHEN clause and specifies a condition establishment of a trusted relationship that DB2 evaluates to determine if the between a DB2 database management triggered SQL statements should be system and an external entity.
Page 571
A recoverable sequence of operations along with its target data type. It has the within a single resource manager, such as general form: an instance of DB2. Contrast with unit of work. CAST(? AS data-type) unit of work (UOW) type 2 indexes...
Page 572
PROCEDURE statement for a native SQL procedure. user-defined function (UDF) v A version of a DBRM is the DBRM A function that is defined to DB2 by that is produced by precompiling a using the CREATE FUNCTION statement program. The DBRM version is...
Page 573
XML locks is similar to the procedures. The WLM application operation of LOB locks. environment determines the address XML node space in which a given DB2 stored The smallest unit of valid, complete procedure runs. structure in a document. For example, a WLM enclave...
Page 574
See Extended Recovery Facility. See XML schema repository. See IBM System z9 Integrated Processor. zIIP z/OS An operating system for the System z product line that supports 64-bit real and virtual storage.
Data Server Driver for JDBC and SQLJ properties 442 calling stored procedures 45 JDBC/SQLJ Driver for OS/390 and z/OS serialized profiles calling stored procedures to IBM Data Server Driver for JDBC and SQLJ serialized CallableStatement 45 profiles 445 cascaded failover, client affinitiesIBM Data Server Driver for...
Page 576
JDBC 21 deregisterDB2XMLObject method 71 databases diagnosing JDBC problems 483 compatibility diagnosing SQLJ problems 483 IBM Data Server Driver for JDBC and SQLJ 4 disability x DataSource interface DISABLE DEBUG MODE SQLJ clause of CREATE PROCEDURE 164...
Page 577
IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS failover support failover support 97 IBM Data Server Driver for JDBC and SQLJ type 2 IBM Data Server Driver for JDBC and SQLJ type 4...
Page 578
74 Java routine 158 JDBC/SQLJ Driver for OS/390 and z/OS properties environment variable settings 160 conversion to IBM Data Server Driver for JDBC and SQLJ Java routine with no SQLJ properties 442 program preparation 187, 188 JDBC/SQLJ Driver for OS/390 and z/OS serialized profiles...
Page 579
DB2Diagnosable class 154 example, Java routine with SQLJ 188 return codes Java routine with no SQLJ 187, 188 IBM Data Server Driver for JDBC and SQLJ errors 382 Java routine with SQLJ 188, 191 roll back JDBC program 183 transaction, JDBC 74...
Page 580
314 executing SQL 112 sqlj.runtime.UnicodeStream 316 execution control 142 SQLSTATEs handling SQLWarning 155 IBM Data Server Driver for JDBC and SQLJ errors 388 host expression 110, 282 SQLWarning implements clause 282 handling in JDBC 81 installing the run-time environment 416...
Page 581
491 SMP/E jobs for loading 437 trace program z/OS Application Connectivity to DB2 for z/OS feature IBM Data Server Driver for JDBC and SQLJ, example 486 environment variables 437 tracing with configuration parameters z/OS UNIX System Services IBM Data Server Driver for JDBC and SQLJ, example 485...
Page 582
™ Application Programming Guide and Reference for Java...
Page 584
Program Number: 5635-DB2 Printed in USA SC18-9842-03...