Mapping time series data types

To enable your Java program to retrieve or send a Calendar, CalendarPattern, orTimeSeries data type to or from the HCL Informix® database, you must create a custom type map.

Procedure

Create a type map with one of the following methods:
  • Create an entry for each time series data type in the type map for each database connection. Entries are valid only for the current connection. The following example makes an entry in the type map of a connection for handling TimeSeries data:
    java.util.Map customTypeMap;
    customTypeMap = conn.getTypeMap();
    
    customTypeMap.put("timeseries(stock_bar)",
        Class.forName("com.informix.timeseries.IfmxTimeSeries"));

    The readSQL method extracts the time series data from the database result set. There must be an entry in the type map for every TimeSeries type that your program uses. You must also add entries for the Calendar and CalendarPattern data types if your program selects those types from the database, for example:

    customTypeMap.put("calendarpattern", 
        Class.forName("com.informix.timeseries.IfmxCalendarPattern"));
    
    customTypeMap.put("calendar",
        Class.forName("com.informix.timeseries.IfmxCalendar"));
  • Create a custom map for the time series data types and reference the map in your application. Use the Builder pattern from the TimeSeriesTypeMap class to create a PatternClassMap for the TimeSeries, Calendar, and CalendarPattern data types. For example, the following map provides case-insensitive access to time series data types:
    Map<String,Class<?>> typeMap = TimeSeriesTypeMap.builder().caseSensitive(false)
    .build();
      connection.setTypeMap(typeMap);

    You can include the type map in your getObject method call, for example:

    ts = (IfmxTimeSeries)rSet.getObject(1, typeMap);