Several JDBC functions were enhanced for i5/OS™ Version 5 Release 2.
Enhanced JDBC functions for i5/OS Version 5 Release 2 include:
ResultSet rs = statement.executeQuery( SELECT * FROM MYCOLLECTION/MYTABLE ); rs.getString(1);
You can now use:
ResultSet rs = statement.executeQuery( SELECT * FROM MYCOLLECTION/MYTABLE ); rs.getString( 'STUDENTS' );
Be aware that accessing parameters by their index results in better performance than accessing them by their name. You can also specify parameter names to set in CallableStatement. Where you might have used the following in CallableStatement:
CallableStatement cs = connection.prepareCall( CALL MYPGM (?) ); cs.setString( 1 );
You can now use:
CallableStatement cs = connection.prepareCall( CALL MYPGM (?) ); cs.setString( 'PARAM_1' );
To use these new methods, you need JDBC 3.0 or later and the Java 2 Platform, version 1.4 (either the Standard or the Enterprise Edition).
Statement s = statement.executeQuery("INSERT INTO MYSCHOOL/MYSTUDENTS (FIRSTNAME) VALUES ('JOHN'"); ResultSet rs = s.getGeneratedKeys(); // Currently the iSeries server supports returning only one auto-generated // key -- the key for the last inserted row. rs.next(); String autoGeneratedKey = rs.getString(1); // Use the auto-generated key, for example, as the primary key in another table
To retrieve auto-generated keys, you need JDBC 3.0 or later, and the Java 2 Platform, version 1.4 (either the Standard or the Enterprise Edition). Retrieving auto-generated keys also requires connecting to a V5R2 or later version of i5/OS.
To use batch support, you need JDBC 2.0 or later and the Java 2 Platform, version 1.2 (either the Standard or the Enterprise Edition).
Holdability is derived in the following order of precedence:
To use these methods, you need JDBC 3.0 or later, and the Java 2 Platform, version 1.4 (either the Standard or the Enterprise Edition). Also, servers running a V5R1 or earlier version of i5/OS are able to use only the holdability specified by the JDBC cursor hold property.