JDBC Importer

JDBC Importer Logo

JDBC Importer Architecture

The following diagram shows how data from a file is imported into a database:

JDBC Importer Data Flow Diagram
  1. A Delimiter Parser converts a file into a set of Strings. Each string represents a row that will be imported into the database.
  2. A Delimiter Parser converts each String into a set of ColumnValues.
  3. A Row Translator may convert the set of ColumnValues by adding or removing ColumnValues, or updating ColumnValues, or returning null to skip the row.
  4. A Column Translator may convert a ColumnValue into another form.
  5. An Import Engine takes the set of ColumnValues and inserts a row into the database.

Note: A Binary Delimiter Parser may be used in place of a Delimiter Parser. The Binary Delimiter Parser returns an Object that represents the row and converts the Object into a set of ColumnValues

Delimiter Parser

net.sourceforge.jdbcimporter.DelimiterParser

The Delimiter Parser converts a file into a set of rows and then converts a row into a set of values. The JDBC Importer passes a java.io.Reader to the Delimiter Parser, calls the 'getNextRow' method to get the next row to import, and calls the 'getValues' method with the next row as a parameter to get the next set of values to import.

To register a new Delimiter Parser in a property file, the following format must be used : delimiter.[alias]=[classname]. The 'alias' parameter is the alias used in the import xml's delimiter type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Delimiter Parser interface.

To register a new Delimiter Parser in an Ant task, the following property element must be added inside the import task element before the connection element: <property name="delimiter.[alias]" value="[classname]"/>. The 'alias' parameter is the alias used in the import xml's delimiter type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Delimiter Parser interface.

Binary Delimiter Parser

net.sourceforge.jdbcimporter.BinaryDelimiterParser

The Binary Delimiter Parser converts a binary file into a set of rows and then converts a row into a set of values. The JDBC Importer passes a java.io.Reader to the Delimiter Parser, calls the 'getNextRow' method to get the next row to import, and calls the 'getValues' method with the next row as a parameter to get the next set of values to import. The 'getRowAsString' method is called when the row needs to be written to a log file.

To register a new Binary Delimiter Parser in a property file, the following format must be used : delimiter.[alias]=[classname]. The 'alias' parameter is the alias used in the import xml's delimiter type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Binary Delimiter Parser interface.

To register a new Binary Delimiter Parser in an Ant task, the following property element must be added inside the import task element before the connection element: <property name="delimiter.[alias]" value="[classname]"/>. The 'alias' parameter is the alias used in the import xml's delimiter type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Binary Delimiter Parser interface.

Row Translator

net.sourceforge.jdbcimporter.RowTranslator

The Row Translators modifies a set of values representing a row. The JDBC Importer calls the 'getValues' method with the entity's definition and values. It uses the return values as the new values for the row. If null is returned then the JDBC Importer will skip the row.

To register a new Row Translator in a property file, the following format must be used : rowtranslator.[alias]=[classname]. The 'alias' parameter is the alias used in the import xml's row translator type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Row Translator interface.

To register a new Row Translator in an Ant task, the following property element must be added inside the import task element before the connection element: <property name="rowtranslator.[alias]" value="[classname]"/>. The 'alias' parameter is the alias used in the import xml's row translator type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Row Translator interface.

Column Translator

net.sourceforge.jdbcimporter.ColumnTranslator

The Column Translator converts a value into another value. The JDBC Importer calls the 'getValue' method with the column's definition and value. It uses the returned value as the new column value for the current row.

To register a new Column Translator in a property file, the following format must be used : columntranslator.[alias]=[classname]. The 'alias' parameter is the alias used in the import xml's column translator type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Column Translator interface.

To register a new Column Translator in an Ant task, the following property element must be added inside the import task element before the connection element: <property name="columntranslator.[alias]" value="[classname]"/>. The 'alias' parameter is the alias used in the import xml's column translator type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Row Translator interface.

Import Engine

net.sourceforge.jdbcimporter.ImportEngine

The Import Engine imports a set of values into the database. The JDBC Importer passes the java.sql.Connection into the Import Engine for use. It calls the 'setEntity' method and the 'init' method before any rows are imported so the Import Engine can setup resources to be used for the importing of the given entity. The JDBC Importer calls the 'importRow' with the next set of values to import into the database. Once all sets of values have been processed, the JDBC Importer calls the 'cleanup' method so the Import Engine can cleanup any resources it used.

To use a new Import Engine in the command-line version, the -Djdbcimporter.engine=[classname] system variable must be specified. The 'classname' parameter is the name of the class (including the package name) that is the implementation of the Import Engine interface. All entities that are specified in the import xml will be imported using the engine.

To use a new Import Engine in the Ant task, the engine attribute must be specified on the import task element. The attribute's value is the name of the class (including the package name) that is the implementation of the Import Engine interface. All entities that are specified in the import task element will be imported using the engine.

JDBC Exporter Logo

JDBC Exporter Architecture

The following diagram shows how data from a file is exported from a database:

JDBC Exporter Data Flow Diagram
  1. An Export Engine reads sets of ColumnValues from the database.
  2. A Column Translator may convert a ColumnValue into another form.
  3. A Delimiter Formatter converts the set of ColumnValues into a String.
  4. A Delimiter Formatter writes the String into a file.

Export Engine

net.sourceforge.jdbcexporter.ExportEngine

The Export Engine exports a set of values from the database. The JDBC Exporter passes the java.sql.Connection into the Export Engine for use. It calls the 'setEntity' method and the 'init' method before any rows are exported so the Export Engine can setup resources to be used for the exporting of the given entity. The JDBC Importer calls the 'exportRow' to retrieve the next set of values to export. Once the Export Engine returns null then the export for the given entity will be completed and the JDBC Exporter calls the 'cleanup' method so the Export Engine can cleanup any resources it used.

To use a new Export Engine in the command-line version, the -Djdbcexporter.engine=[classname] system variable must be specified. The 'classname' parameter is the name of the class (including the package name) that is the implementation of the Export Engine interface. All entities that are specified in the export xml will be exported using the engine.

To use a new Export Engine in the Ant task, the engine attribute must be specified on the export task element. The attribute's value is the name of the class (including the package name) that is the implementation of the Export Engine interface. All entities that are specified in the export task element will be exported using the engine.

Column Translator

See above

Delimiter Formatter

net.sourceforge.jdbcexporter.DelimiterFormatter

The Delimiter Formatter converts a set of values into a string that represents a row and writes a set of rows into a file. The JDBC Exporter passes a java.io.Write to the Delimiter Formatter, calls the 'formatValues' method with the next set of values. The resulting string will be passed into the 'writeNextRow' method to complete the writing of the row to the file.

To register a new Delimiter Formatter in a property file, the following format must be used : delimiter.[alias]=[classname]. The 'alias' parameter is the alias used in the export xml's delimiter type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Delimiter Formatter interface.

To register a new Delimiter Formatter in an Ant task, the following property element must be added inside the export task element before the connection element: <property name="delimiter.[alias]" value="[classname]"/>. The 'alias' parameter is the alias used in the export xml's delimiter type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Delimiter Formatter interface.

Data Generator Logo

Data Generator Architecture

The following diagram shows how data is generated and written to a file:

Data Generator Data Flow Diagram
  1. A Column Value Generator generates sets of ColumnValues.
  2. A Delimiter Formatter converts the set of ColumnValues into a String.
  3. A Delimiter Formatter writes the String into a file.

Column Value Generator

net.sourceforge.datagenerator.ColumnValueGenerator

The Column Value Generator generates values for a specific column in an entity. The Data Generator calls the 'setColumnDef' method with the current column's definition. It then calls the 'getDependencies' method to retrieve the list of columns whose values must exist before the Column Value Generator can generate values. By calling the 'setDependentValue' and the 'setDependentValues' methods, the Data Generator gives the Column Value Generator the dependent values. Once all dependent values are generated, the Data Generator calls the 'getNextColumnValue' method to retrieve the next generated value for the column.

To register a new Column Value Generator in a property file, the following format must be used : generator.[alias]=[classname]. The 'alias' parameter is the alias used in the generate xml's generator type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Column Value Generator interface.

To register a new Column Value Generator in an Ant task, the following property element must be added inside the generate task element before the connection element: <property name="generator.[alias]" value="[classname]"/>. The 'alias' parameter is the alias used in the generate xml's generator type attribute and 'classname' is the name of the class (including the package name) that is the implementation of the Column Value Generator interface.

Delimiter Formatter

See above