Configuring the XML file. A migration is described in an XML file containing all steps that should be performed.

    <?xml version="1.0" encoding="UTF-8"?>
    <migration>

      <databank>
        <source
          driverType="org.javahispano.dbmt.migrations.MigrationCSVSource"
          driver="delimeter=; codepage=Windows-1251 trim=true"
          url="c:\" 
        />
        <target
          driverType="org.javahispano.dbmt.migrations.MigrationJDBC"
          driver="com.sap.dbtech.jdbc.DriverSapDB"
          url="jdbc:sapdb://127.0.0.1/DATABASE_TGT"
          username="dbuser"
          password="dbpwd"
          quoted-names="false"
        />
      </databank>
      <log level="INFO"/>

      <steps>
       <step name="EXAMPLE_STEP"
              skip='false'
              source_table="SOURCE_TABLE.csv"
              target_table="TARGET_TABLE"
              clear_target="false"
              where="INTERNAL is null OR INTERNAL=false"
              log_level="OFF"
              slice_size="1000"
              stop_on_error="true"
         >
          <field from="ID"/>
          <field from="NAME" to="OTHER_NAME"/>
          <field from="substr(DESC,1,2)||'_suffix'" to="NEW_DESC"/>
          <field from="true" to="LOGIC_FIELD"/>
       </step>
      </steps>
    </migration>

The databank tag.

FormatJava class for sourceJava class for targetRequirements
JDBCorg.javahispano.dbmt.migrations.MigrationJDBCorg.javahispano.dbmt.migrations.MigrationJDBCJDBC 2.0
CSVorg.javahispano.dbmt.migrations.MigrationCSVSourceorg.javahispano.dbmt.migrations.MigrationCSVTarget
DBForg.javahispano.dbmt.migrations.MigrationDBFSourceorg.javahispano.dbmt.migrations.MigrationDBFTargetJavaDBF 0.4.0 with the following patch
XMLorg.javahispano.dbmt.migrations.MigrationSaxXMLSource-JAXP 1.0
TXT-org.javahispano.dbmt.migrations.MigrationFreemarkerTargetFreemarker template engine is used for generating textual files

In this tag we are defining types of the source and the target for this migration, giving the URL and driver parameters to be used. URL and driver parameters are dependent on types of the source and the target.

Note: Databanks org.javahispano.dbmt.MigrationSaxXMLSource and org.javahispano.dbmt.MigrationFreemarkerTarget are not compatible.

This file will be used for all steps. Full file name is url+file. If this parameter is omited then each step will use own file with name equals to step's name

FormatAttributeParameterSourceTargetDescription
JDBCurlURL++URL for the connection
JDBCdriverDRIVER++Name of the JDBC driver
JDBCusernameDB USERNAME++Username for the connection
JDBCpasswordDB PASSWD++Password for the connection
JDBCquoted-namesquoted++RDBMS requires names with double quotes
CSVurlURL++URL for CSV file
CSVdriverdelimeter++Fields delimeter in CSV file. By default it is comma
CSVdrivercodepage++Codepage of CSV file. By default it is Java default codepage
CSVdrivertrim+-If true then removes leading and trailing whitespace; do nothing otherwise
DBFurlURL++URL for DBF file
DBFdrivercodepage++Codepage of DBF file. By default it is Java default codepage
XMLurlURL+-URL for XML file. Supports jar protocol (jar:http://example.org/archive.jar!/)
XMLdriverdriver+-Path in XML file of rows. By default path is 'select.row'. Minimum number of tags are two.
TXTurlURL-+URL for TXT file.
TXTdriverfile-+File name where output of Freemarker will be stored.
TXTdrivercodepage++Codepage of output file. By default it is Freemarker's default codepage
TXTdrivertemplate_codepage++Codepage for templates. By default it is Freemarker's default codepage
TXTdriverappend-+If true then file will be appended. Otherwise it will be recreated. This option is valid only if parameter 'file' is specified. 'true' is by default

Pay attention that JDBC and DBF drivers are not included in DBMT's distribution, so you should add them to your classpath. Of course this tag is mandatory.

The log tag.

DBMT uses 'org.javahispano.dbmt' JDK14 logger to informate about migration process.

Log levelMessages
FINESTTarget's errors
FINENumber of inserted rows in commit time
INFOInformation about current process, number of total inserted, filtered, skipped by target's error
SEVEREFatal error

In each step there is attribute 'log_level'. MigrationTarget can use for logging all insert commands into file. Now only MigrationJDBC uses this attribute.

The steps tag.

Steps are the most important part of a migration and in every step it is defined how the fields of a table should be changed to fit in the new schema. You can write so many step tags as tables we want to migrate.

    <step name="EXAMPLE_STEP"
          skip='false'
          source_table="SOURCE_TABLE.csv"
          target_table="TARGET_TABLE"
          clear_target="false"
          where="INTERNAL is null OR INTERNAL=false"
          log_level="OFF"
          slice_size="1000"
          stop_on_error="true"
     >
      FIELDS
    </step>
Format Attribute Description
ALLnameName of the step. Using in logs.
ALLskipIf false then the step will be skipped
By default it is false
ALLwhereSQLJEP expression. Variables are names of columns in SOURCE_TABLE
ALLstop_on_errorIf false and an exception occurs in MigrationTarget then the exception will be logged and migration process will be continued
By default it is true
JDBCsource_table* Select statement. For example 'SELECT f1,f2,f3 from SOURCE_TABLE where id>1000'
* Callable statement. For example 'call dbproc(1,2)'
* Table name. For exmaple 'SOURCE_TABLE'. In this case the following statement will be used 'SELECT * from SOURCE_TABLE'
JDBCtarget_tableTable name
JDBCclear_target* If true then the following statement will performed 'DELETE from TARGET_TABLE'.
* Callable statement. For example 'call my_clear'.
* If false then do nothing.
By default it is false
JDBClog_level* 'FINEST' - all SQL insert statements will be stored in the file 'EXAMPLE_STEP.sql' in the current working directory.
* 'FINER' - all SQL execute time errors of insert stamenets will be stored in file 'EXAMPLE_STEP.sql'.
This attribute is valid only if stop_on_error="false".
By default log_level is OFF
JDBCslice_sizeNumber inserted rows into target table without commits. 0 means commit after all rows
XMLsource_tableMigrationSaxXMLSource can get XML files from JAR archives. In this case this attribute is name of XML file in JAR archive. Otherwise path to XML file is source.url+source_table
XMLtarget_tablenot implemented
XMLlog_levelnot implemented
XMLslice_sizenot implemented
CSVsource_tableCSV source file. Full path to CSV file is source.url+source_table
CSVtarget_tableCSV target file. Full path to CSV file is target.url+target_table
CSVclear_targetIf false then CSV file will be appended. By default it is false
CSVlog_levelnot used
CSVslice_sizenot used
DBFsource_tableDBF source file. Full path to DBF file is source.url+source_table
DBFtarget_tableDBF target file. Full path to DBF file is target.url+target_table
DBFclear_targetIf false then DBF file will be appended. By default it is false
DBFlog_levelnot used
DBFslice_sizenot used
TXTsource_tablenot used
TXTtarget_tableFreemarker's template file. Full path to template file is target_table. URLs are supported. By default Freemarker uses FileTemplateLoader for loading templates. If an URL is specified in 'target_table' attribute then URLTemplateLoader is used. In the template the source table there is as the collection with name 'SOURCE'.
TXTclear_targetIf false then output file will be appended. By default it is false. This attribute is valid only if there is no 'file' parameter in 'driver' attribute of 'target' tag.
TXTlog_levelnot used
TXTslice_sizeNumber inserted rows into target table without flushes. 0 means flush after all rows

Next we have to write how the fields will be processed.

  <field from="ID"/>
  <field from="NAME" to="OTHER_NAME"/>
  <field from="substr(DESC,1,2)||'_suffix'" to="NEW_DESC"/>
  <field from="true" to="LOGIC_FIELD"/>

'from' attribute is mandatory. It can contain name of the field in source table or SQLJEP expresson where variables are names of columns in the source table.

If 'to' is absent then it will be get the same as 'from'.

Some MigrationTarget objects may not have information about types of fields. For example MigrationDBFTarget. When MigrationDBFTarget creates new DBF file it doesn't have information about fields types. And some MigrationSource objects can convert types. For example MigrationDBFSource represents dates only as java.util.Date type but it can convert dates to java.sql.Time or java.sql.Timestamp or java.sql.Date.

For this purposes tag 'field' has attribute 'type'.

Mapping 'type' attribute to Java class.

'type' fieldJava class
stringjava.lang.String
shortjava.lang.Short
integerjava.lang.Integer
longjava.lang.Long
logicaljava.lang.Boolean
fixed(m,n) or bigdecimaljava.math.BigDecimal
timejava.sql.Time
datejava.sql.Date
timestampjava.sql.Timestamp