Please enable JavaScript to view this site.

Altova MapForce 2020 Professional Edition

This example uses Eclipse as Java IDE. To begin, generate Java code from the DB_CompletePO sample mapping available in the <Documents>\Altova\MapForce2020\MapForceExamples\ directory, and then import the project into Eclipse.

cg_eclipse_DB_CompletePO

Sample MapForce-generated Java application (Eclipse IDE)

To edit the generated Java console application, locate the main(String[] args) method of your generated application (see the screen shot above). If you did not change the default base package name before generating code, this method is in the MappingConsole class of the com.mapforce package. Otherwise, it is in the MappingConsole class of your custom defined package.

 

To edit the generated Java dialog application, locate the place in the code where the run method is invoked from your generated application. If you did not change the default base package name before generating code, the run method is invoked from the class called MappingFrame.java of the com.mapforce package.

 

The following code sample illustrates an extract from the main method in the generated Java console application. The mapping sources and targets are highlighted in yellow and are defined as parameters to the run method. Since this mapping uses a database connection, the corresponding parameter has a special structure. Namely, the connection consists of the connection string (in this case, jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=CustomersAndArticles.mdb), as well as two empty arguments intended for the Username and Password (in clear text) for those databases where this data is necessary.

 

Note that the file paths in the code below have been changed from absolute to relative.

 

com.altova.io.Input ShortPO2Source = com.altova.io.StreamInput.createInput("ShortPO.xml");
com.altova.io.Output CompletePO2Target = new com.altova.io.FileOutput("CompletePO.xml");

 
MappingMapToCompletePOObject.run(
                com.altova.db.Dbs.newConnection(
                    "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=CustomersAndArticles.mdb",
                    "",
                    ""),
                ShortPO2Source,
                CompletePO2Target);

 

 

To define custom mapping source or target files:

Locate the parameters passed to the run method and edit them as required. In the sample above, com.altova.db.Dbs.newConnection and ShortPO2Source is the mapping input and CompletePO2Target is the mapping output.

 

 

To add extra error handling code:

Edit the code below the        catch (Exception e) code (in case of a Java console application)

Edit the code below the catch (Exception ex) code (in case of a Java dialog application)

 

For instructions on how to change the data type of parameters supplied as mapping input/output, see Changing the data type of the mapping input/output (C#, Java).

© 2019 Altova GmbH