Many additions were made to JDBC support in IBM® i 7.1.
The JDBC 4.0 interface specification adds new methods and classes for XML data type support. IBM Toolbox for Java implements XML support in its JDBC 4.0 driver. This allows JDBC clients easy access to IBM i 7.1 XML support.
You can set the data in the JDBC SQLXML object by passing in various data types such as Java String. As is done for all other text column data types, IBM Toolbox for Java or the Database Management System (DBMS) does the necessary conversions of XML data to match column CCSID for the XML column.
The DBMS reads and writes XML data using SQL locators.
The DBMS may optimize XML data when appropriate. For example an empty tag, "<tag><tag/>", becomes "</tag>". Generally if input XML data that is not in UTF-16 and has an XML declaration along with an encoding specified, it should not be passed into JDBC through PreparedStatement.setString. This is because the data in Strings is UTF-16 and it does not match the specified encoding.
There are some rules that govern how XML declarations are returned from a query. JDBC handles the declaration visibility depending on which type ResultSet getter method called. Methods that return characters, such as getString() and getClob(), do not return the XML declaration with the data. Methods that return binary data, such as getBytes() and getBlob(), will return the XML declaration. This is due to the difference in XML declaration encoding and the CCSID of the actual XML column on the table. Note that calling getString() will return a Unicode String, which could be different from the CCSID specified in the XML declaration encoding. Because of this anomaly, the declaration is simply discarded unless accessed with binary getter methods. The retrieval of XML tags with methods such as getString will allow XML data to be easily concatenated with other XML data since it will have its declaration removed already.
Database metadata is obtained by calling the various methods of the AS400JDBCDatabaseMetaData class. Starting with IBM i 7.1, the default behavior of IBM Toolbox for Java JDBC is to obtain this metadata from a set of standard system stored procedures. This brings IBM Toolbox for Java into alignment with IBM i native JDBC support in addition to JDBC drivers on other platforms. Prior to IBM i 7.1, IBM Toolbox for Java obtained the metadata from the host servers ROI data server. This approach has worked well, and has also kept IBM Toolbox for Java in alignment with ODBC, .net, and other IBM i clients. The problem with this approach though, is that across IBM, all JDBC DB2® drivers should function the same way. This can be achieved by using a set of system stored procedures that are common across all of the DB2 platforms. These system stored procedures are called to obtain system database metadata.
In order to provide backwards compatibility of the metadata functionality, a new connection property, "metadata source", can be used to force IBM Toolbox for Java JDBC to use the old method of retrieval of database metadata.
Lock timeouts and deadlocks can occur under the isolation levels that perform row-level locking, especially with applications that are not designed to prevent such problems. Some high throughput database applications cannot tolerate waiting on locks that are issued during transaction processing, and some applications cannot tolerate processing uncommitted data, but still require non-blocking behavior for read transactions.
Under the new currently committed semantics, if currently committed is enabled then only committed data is returned, as was the case previously, but now readers do not wait for writers to release row locks. Instead, the data returned to readers is based on the currently committed version; that is, data prior to the start of the write operation.
This feature also implements a way to direct the database manager to wait for the outcome when encountering data in the process of being updated.
IBM Toolbox for Java supports the IBM i 7.1 SQL array data type in stored procedure parameters. Arrays of all of the various DB2 types are supported except data that is returned in a locator.
IBM Toolbox for Java JDBC adds support for arrays as IN, OUT, and INOUT parameters to stored procedures. However, ResultSets returned from stored procedures or other queries containing arrays is not supported.
JDBC supports the calling of stored procedures in the java.sql.CallableStatement class, which IBM Toolbox for Java implements in AS400JDBCCallableStatement.
IBM i 7.1 DBMS has added support for 128 byte schema names. IBM Toolbox for Java JDBC is also adding support for long schema names.
IBM Toolbox for Java converts schemas from Java Strings to the system CCSID prior to sending the data to the host DBMS. IBM Toolbox for Java does allow a long schema name as the default-schema. However, long schema names in the library list is not supported. If a long schema name is specified in the "libraries" property, a warning back from host and trace that the library was not added will be issued. If a long schema name is specified as the first name in the "libraries" property, then IBM Toolbox for Java still sets the name as the default schema, but does not add it to the library list. Clients which need to use long schema names in the library list have to make use of the DB2 SET PATH command.
Database metadata also supports long schema names for parameters and ResultSets returned.
