Sqlch comes with a number of command-line tools that are used to set up Sqlch for use in your builds or to help indentify problems with your database or drivers.
All the tools are standard Java classes and therefore must be run using the Java run-time environment. The environment necessary to run Sqlch is the same as that described on this page.
If a user invokes the commands without arguments, a usage message is printed.
The ConvertCsvToDatFile tool can convert a CSV file (as might be generated by widely-used spreadsheet packages) into a DAT file that can be accepted by Sqlch.
The first line of the CSV file should be the names of the columns. Subsequent lines should be the data itself. The row data should be in the correct format for the ColumnHelpers you intend to use for the columns.
Note: CSV files do not allow you to specify the distinction between a "null" and an empty string (but Sqlch DAT files do). In order to deal with this, by default the tool treats all empty strings as nulls since this is the most likely representation for null that spreadsheets will contain. Users can use a "null token" parameter to specify an alternative string that indicates null. When choosing a "null token" users should pick something that will not occur naturally in the spreadsheet.
ConvertCsvToDatFile takes the following arguments:
Argument | Description | Mandatory? |
-input | The name of the CSV file to convert | Yes |
-output | The name of the DAT file to generate | Yes |
-nulltoken | The token in CSV files used to indicate a null value (empty String by default) | No |
The ConvertDatToCsvFile tool can convert a Sqlch DAT file into a CSV file that can be easily read by common spreadsheet packages.
As per the Sqlch format, the first line of the DAT file should be the names of the columns. Subsequent lines should be the data itself.
Note: CSV files do not allow you to specify the distinction between a "null" and an empty string (but Sqlch DAT files do). In order to deal with this, by default the tool generates all empty strings when it encounters nulls in the input DAT file. Users can use a "null token" parameter to specify an alternative string that indicates null. When choosing a "null token" users should pick something that will not occur naturally in the spreadsheet.
ConvertDatToCsvFile takes the following arguments:
Argument | Description | Mandatory? |
-input | The name of the DAT file to convert | Yes |
-output | The name of the CSV file to generate | Yes |
-nulltoken | The token in CSV files used to indicate a null value (empty String by default) | No |
The CreateDataSet tool can create a sample Sqlch dataset file given database connection information and a table search criteria. The purpose of the CreateDataSet tool is to allow users to get started if they already have an existing database they wish to build with Sqlch. The file produced by CreateDataSet is unlikely to be perfect, but should serve as a suitable starting point.
For each table CreateDataSet finds, an entry is added to the dataset file describing the table (as reported by the driver), setting a suitably named data-file.
Users may wish to add further sub-elements and attributes to the dataset file. See the datasets page for more information on dataset files.
CreateDataSet takes the following arguments:
Argument | Description | Mandatory? |
-driver | The class name of the JDBC driver to use (must be on the CLASSPATH). | Yes |
-url | The JDBC URL to use to connect to the database. | Yes |
-user | The JDBC username to use to connect to the database. | No |
-pass | The JDBC password to use to connect to the database. | No |
-catalog | The database catalog. The % wildcard is supported. Not specifying this argument indicates no criteria and is the equivalent of specifying "%". | No |
-schema | The database schema. The % wildcard is supported. Not specifying this argument indicates no criteria and is the equivalent of specifying "%". | No |
-table | The database table name. The % wildcard is supported. Not specifying this argument indicates no criteria and is the equivalent of specifying "%". | No |
-file | The path of the dataset file to create. | Yes |
The CreateEmptyDats tool can create a set of empty datafiles for a supplied dataset given database connection information and the dataset file. The purpose of the CreateEmptyDats tool is to act as a starting point for users that have a schema but no data yet and wish to add data to their database via the data files.
See the the data files page for more information on the data files format.
CreateEmptyDats takes the following arguments:
Argument | Description | Mandatory? |
-driver | The class name of the JDBC driver to use (must be on the CLASSPATH). | Yes |
-url | The JDBC URL to use to connect to the database. | Yes |
-user | The JDBC username to use to connect to the database. | No |
-pass | The JDBC password to use to connect to the database. | No |
-input | The name of the dataset file | Yes |
-output | The name of the directory to output the dat files to | Yes |
The DependencyFileGenerator tool can create a Sqlch dependency file given database connection information and one or more dataset files. The purpose of the DependencyFileGenerator tools is to create a dependency file that users can alter. This is useful if the JDBC driver you are using is misreporting dependencies. The dependency file can be used to check the dependencies are not being reported correctly and can be corrected and passed to Sqlch to use rather than using the information reported by the JDBC driver.
See the dependency file page for more information on dependency files.
DependencyFileGenerator takes the following arguments:
Argument | Description | Mandatory? |
-driver | The class name of the JDBC driver to use (must be on the CLASSPATH). | Yes |
-url | The JDBC URL to use to connect to the database. | Yes |
-user | The JDBC username to use to connect to the database. | No |
-pass | The JDBC password to use to connect to the database. | No |
-file | The path of the dependency file to create. | Yes |
-datasets | One or more dataset files | Yes |
-defaultSchema | The name of the schema you wish to use by default. If the schema is not specified in the dataset file(s), this schema will be used by default. For each table in the dependency file being generated, if the schema of a table matches the defaultSchema, it is not output as part of the table identifier. | No |
-defaultCatalog | The name of the catalog you wish to use by default. If the catalog is not specified in the dataset file(s), this catalog will be used by default. For each table in the dependency file being generated, if the catalog of the table matches the defaultCatalog, it is not output as part of the table identifier. | No |
A simple command that can be used to check database connection information and print information about the driver and the database that you might need when using Sqlch.
Example output:
Database is [MySQL] version [4.0.18-max-nt] Driver: Name=[MySQL-AB JDBC Driver] Driver version=[mysql-connector-java-3.0.11-stable ( $Date: 2004/10/24 20:00:45 $, $Revision: 1.7 $ )], major=[3], minor=[ Database calls a JDBC catalog a [database] Database catalog separator=[.] Database calls a JDBC schema a []
DescribeDb takes the following arguments:
Argument | Description | Mandatory? |
-driver | The class name of the JDBC driver to use (must be on the CLASSPATH). | Yes |
-url | The JDBC URL to use to connect to the database. | Yes |
-user | The JDBC username to use to connect to the database. | No |
-pass | The JDBC password to use to connect to the database. | No |
The DescribeRelationships tool reports the foreign-key relationships known to the JDBC driver for a given table. This can be used to help diagnose issues with JDBC drivers. The information supplied to DescribeRelationships must resolve to a single database table or an error will result.
DescribeRelationships takes the following arguments:
Argument | Description | Mandatory? |
-driver | The class name of the JDBC driver to use (must be on the CLASSPATH). | Yes |
-url | The JDBC URL to use to connect to the database. | Yes |
-user | The JDBC username to use to connect to the database. | No |
-pass | The JDBC password to use to connect to the database. | No |
-catalog | The database catalog. The % wildcard is supported. Not specifying this argument indicates no criteria and is the equivalent of specifying "%". | No |
-schema | The database schema. The % wildcard is supported. Not specifying this argument indicates no criteria and is the equivalent of specifying "%". | No |
-table | The database table name. The % wildcard is supported provided that only a single table is matched. | Yes |
The DescribeTables tool describes the metadata associated with a set of tables specified by the user to help them understand the contents of their database.
DescribeTables takes the following arguments:
Argument | Description | Mandatory? |
-driver | The class name of the JDBC driver to use (must be on the CLASSPATH). | Yes |
-url | The JDBC URL to use to connect to the database. | Yes |
-user | The JDBC username to use to connect to the database. | No |
-pass | The JDBC password to use to connect to the database. | No |
-catalog | The database catalog. The % wildcard is supported. Not specifying this argument indicates no criteria and is the equivalent of specifying "%". | No |
-schema | The database schema. The % wildcard is supported. Not specifying this argument indicates no criteria and is the equivalent of specifying "%". | No |
-table | The database table name. The % wildcard is supported. Not specifying this argument indicates no criteria and is the equivalent of specifying "%". | No |
Sqlch SourceForge Distribution: 0.1Alpha8 20041026 2208