Using the expandArrayResultSet property

The IMS Universal JDBC driver allows for easier access to Array datatype fields using the expandArrayResultSet property.

This property enables IMS Universal JDBC driver to create an ArrayResultSet with the array elements as the actual fields in the ResultSet instead of a Struct object containing those elements as the only entry into that ResultSet.

This property indicates whether the IMS Universal JDBC driver would flatten an array when an ArrayResultSet is created. If this property is set to true, the array will be expanded to its individual array sub fields in the ArrayResultSet. If set to false, the application will receive an array object for each array instance that exists within the ArrayResultSet. The default value is set to false.

Programming example to use expandArrayResultSet property

The following is an example of obtaining a ResultSet using the expandArrayResultSet property.

 Properties props = new Properties();
props.setProperty("expandArrayResultSet", "true");
ds.setProperties(props);
        Connection conn = ds.getConnection();

Statement st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);

String selectSql = "SELECT * FROM ARRAY WHERE HOSPITAL_HOSPCODE='R1210010000A'";
st.executeQuery(selectSql);
rs = st.getResultSet();
while (rs.next()) {
Array accountArray = rs.getArray("ACCOUNTS");
ResultSet arrayResultSet = accountArray.getResultSet();

// delete first row
arrayResultSet.first();
arrayResultSet.deleteRow();

// move two relative to 1
arrayResultSet.relative(2);

// Start insert at position 3
arrayResultSet.moveToInsertRow();
arrayResultSet.updateString("TYPE", "VISA");
arrayResultSet.updateString("ACCOUNT_DATA", "1111XXXXXXXX4444");
arrayResultSet.updateString("EXPIRATION", "0112");
arrayResultSet.updateString("SECURITY_CODE", "9111");
arrayResultSet.insertRow();

// move to last remembered position
arrayResultSet.moveToCurrentRow();

// go to the last row
arrayResultSet.last();

// go back 4 relative to position 5. should be at 1
arrayResultSet.relative(-4);

// Update string at position 3.
arrayResultSet.updateString("EXPIRATION", "2099");
arrayResultSet.updateRow();

// Commit all changes
rs.updateRow();
}
rs.close();
conn.close();

Enabling the expandArrayResultSet property

Enabling the expandArrayResultSet property in the server.xml for use with the IMS Universal Driver

<connectionFactory jndiName="HOSP_JDBC_T4_EXPANDED">
<properties.imsudbJLocal databaseName="BMP255" datastoreName="IMS1" datastoreServer="localhost" driverType="4" password="myPassword" portNumber="{DRDA_PORT}" user="myUserID" expandArrayResultSet="true"/>
</connectionFactory>

Enabling the expandArrayResultSet in an IMSManagedConnectionFactory object.

IMSManagedConnectionFactory imsManagedConnectionFactory = new IMSManagedConnectionFactory();
imsManagedConnectionFactory.setExpandArrayResultSet(true);

Using the Driver Manager to enable the expandArrayResultSet property via a JDBC URL

String url=""jdbc:ims://tst.svl.ibm.com:8888/class://"
   + "BMP2.BMP2DatabaseView:datastoreName=IMS1;"
   + "loginTimeout=10;sslConnection=true;user=myUserID;password=myPassword;expandArrayResultSet=true;";
Connection conn = DriverManager.getConnection(url);

or

Connection conn = null;

// Create Properties object
Properties props = new Properties();  

/ Enable expandArrayResultSet
props.put("expandArrayResultSet", "true");

// Create connection
conn = DriverManager.getConnection
("jdbc:ims://tst.svl.ibm.com:8888/class://BMP2.BMP2DatabaseView",
props);

Enabling the expandArrayResultSet property on an IMSDataSource object.

IMSDataSource

IMSDataSource ds = new IMSDataSource();
Properties props = new Properties();
props.setProperty("expandArrayResultSet", "true");
props.setProperty("llField", "false");
ds.setProperties(props);

Or

IMSDataSource ds = new IMSDataSource();
ds.setExpandArrayResultSet(true);