Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

JDBC2XML Usage

This section refers to the command-line tool. For information on the uses of the java library, please refer to our java documentation.

Commands

JDBC2XML provides several commands, triggering different operations.

The following command overview only shows the absolut minimal number of options.

Usually more options are needed, especially --user--password, and (Linux only, see bottom) --jdbc-drivers.

See far below for a full list of options, as well as examples for JDBC URLs.

Dumping a DB to XML

No Format
jdbc2xml --url <jdbc-url> --user <jdbc-user> --password <jdbc-password> --file <path-to-file>

See below for details and example for JDBC URLs.

Restoring a DB from XML

No Format
xml2jdbc --file <path-to-file> --url <jdbc-url> --user <jdbc-user> --password <jdbc-password> 

Copying from one DB to another

No Format
jdbc2jdbc --from-url <jdbc-url> --to-url <jdbc-url> --user <jdbc-user> --password <jdbc-password>

Parse and copy an XML file

This can be useful for extracting a schema from a database (see options below)

No Format
xml2xml --from-file <path-to-file> --to-file <path-to-file>

Test DB connection and server status

No Format
jdbcping --url <jdbc-url> --user <jdbc-user> --password <jdbc-password>

Extract parts of a DB

No Format
jdbcextr --url <jdbc-url> --user <jdbc-user> --password <jdbc-password> --file <path-to-file>

JDBC URLs

JDBC URLs basically look like jdbc:servertype://host[:port]/db?options., but some Databases and/or JDBC Drivers like other variants.

Typical examples are:

No Format
# MySQL
jdbc:mysql://localhost:3306/MYDATABASE?useCursorFetch=true
 
# MSSQL
jdbc:sqlserver://localhost:1433;databaseName=MYDATABASE;

The use of cursor fetching in mysql is highly recommended in order to circumvent java heap space exceptions while dumping the content of large tables.

Full list of options

Database access

JDBC URL to access the DB.

No Format
--from-url "jdbcurl"
--to-url "jdbcurl"
--url "jdbcurl"

User to access the DB (some drivers can parse that from the URL):

No Format
--from-user user
--to-user user
--user user

Password to access the DB (some drivers can parse that from the URL):

No Format
--from-password password
--to-password password
--password password

File access

Win32 wrapper needs absolut paths. The given filenames may contain compressed input. The implementation instantiates an appropriate inflating/deflating stream if the filename ends with .gz or .bz2

No Format
--from-file file
--to-file file
--file file

Restrict processing to tables

Whitelist tables (comma seperated, without whitespace)

No Format
--tables table1,table2,...

Blacklist tables

No Format
--exclude-tables table1,table2,...

Do not include table data in dump (creates a full schema from a populated database):

No Format
--no-data

Ignore constraints

No Format
--no-constraints

Combined--no-data and --no-constraints

No Format
--schema-only

Expert options

Drop the affected tables before actually importing a dump. If --tables or --exclude-tables is given, only tables affected by the specified filter are dropped.

No Format
--drop-tables

Overrides the default bzip2 output compression, if --to-file ends with .bz2

No Format
--compression <n>

Force a timezone

No Format
--timezone timezoneid

allows to select a JDBC driver, overriding autoselection

No Format
--from-driver drivername
--to-driver drivername
--driver drivername

Linux only: add given drivers to the classpath

No Format
--jdbc-drivers jarfilename[;jarfilename...]

Options for jdbc behaviour

Change the batch size for inserts (def.: 1000)

No Format
--batch-size n

Fetch the contents of the database using a read-only transaction

No Format
--transactional

Options for xml reading

Enable schema checking on the xml file

No Format
--check-xml-schema

Create an extra index on each foreign key

No Format
--create-fk-indices

Options for xml creation

Force or supress pretty printing of xml data

No Format
--pretty, --no-pretty

Forces the transformation of SQL identifiers to lower case

No Format
--to-lower

Force the transformation of SQL identifiers to upper case

No Format
--to-upper

Write internal indices, which are generated by the RDBMS

No Format
--keep-internal-indices

Output Verbosity

The default log level prints FatalError and Warning logs

Suppresses any output except for the return code

No Format
--quiet

Increase log-level to Info

No Format
--verbose

Log everything (command-line spam warning)

No Format
--debug

Activate loggers in wrapper scripts (only useful if you know what you're doing)

No Format
--debug-startup

Driver packages and paths, and other Backend specific tips

See