Using the DB2 spatial data source

The IlvDB2DataSource class is an IlvMapDataSource for reading georeferenced objects from a DB2® spatial database. It wraps up all operations (connecting to database, reading features, rendering them to graphic objects) in a convenient way.
To read a map stored in an DB2 spatial database:
  1. Create a connection to the DB2 Spatial database:
    IlvDB2ConnectionInfo theDB2Connection=new IlvDB2ConnectionInfo();
    theDB2Connection.setHostName("server_hostname");        
    theDB2Connection.setHostPort("50001");
    theDB2Connection.setUser("a_db2_user");
    theDB2Connection.setPassword("password");
    theDB2Connection.setDatabaseName("database_name")
    
  2. Create a data source with this connection as a parameter:
    // we want to fetch layer "A_DB2_USER.FLOODZONES.LOCATION.SRID=100002"
    String layerName="A_DB2_USER.FLOODZONES.LOCATION.SRID=100002";
    IlvDB2DataSource dataSource=new IlvDB2DataSource(DB2Connection, layerName);
    
    To obtain a list of layers, see Getting a list of layers
  3. Set parameters on this data source to use load-on-demand, if needed:
    boolean useTiling = true;
    int rowCount = 5;
    int columnCount = 5;
    dataSource.setTilingParameters(useTiling, rowCount, columnCount);
    
  4. Connect this data source to the manager of the view:
    dataSource.setManager(getView().getManager());
  5. Insert the data source map layer into the layer tree (You first need to retrieve the layer model from the property of the manager):
    IlvMapLayerTreeModel mltm = IlvMapLayerTreeProperty.GetMapLayerTreeModel(v.getManager());
    mltm.addChild(null, dataSource.getInsertionLayer());
    
  6. Insert the data source into the data source tree. You first need to retrieve the data source model from the property of the manager:
    IlvMapDataSourceModel dataSourceModel = 
    IlvMapDataSourceProperty.GetMapDataSourceModel(manager);
    dataSourceModel.insert(dataSource);
    
  7. Finally, start the data source (or the whole model, if you have more than one data source):
    dataSource.start();