Configuring QuerySurge Connections for Fixed Width Flat Files in a Zip Archive
QuerySurge's JDBC-compliant Flat File driver can connect to zip archives in addition to connecting directly to files. The setup in the Connection Wizard uses the Connection Extensibility option, so you'll need both a hand-written schema.xml file as well as well as a properly constructed JDBC URL.
The Sample Fixed Width Flat File
The file has the following characteristics. The file name has a ".txt" extension. Headers are not found in this file; it contains only data rows. The file contains 6 columns, specified by the positions:
The column layout (with column names superimposed) looks like:
A sample row of data looks like:
The Schema File
The schema file for this fixed width file is:
<table name ="*.txt" separator = "fixed">
<!-- 1-5,6-13,14-28,29-46,47-47,48-49 -->
<column name = "RowId" begin = "1" end = "5" type = "Varchar" size="32"/>
<column name = "Purch_ID" begin = "6" end = "13" type = "Double"/>
<column name = "Last_Name" begin = "14" end = "28" type = "Varchar" size="32"/>
<column name = "Item_Name" begin = "29" end = "46" type = "Varchar" size="32"/>
<column name = "S" begin = "47" end = "47" type = "Varchar" size="32"/>
<column name = "Qu" begin = "48" end = "49" type = "Integer"/>
In addition to specifying each of the column widths and their names and data types, the schema file also supplies a wildcarded filename: "*.txt".
The JDBC URL
The flat file driver URL protocol for files in Zip archives must contain a special "zip" token signifying that the target file is contained in a Zip archive. In addition, it must specify the Zip file's full path, and the full path to the schema.xml file in the schema property. Another important property is the fileExtension property, which specifies the extension of the data file. Other driver properties are also included, such as suppressHeaders, which is set to true because there are no headers in our sample file. In addition, we specify commentLine and escapeEOLInQuotes properties.
Note: Even for Windows-type paths, the forward slash is used.
Setup and Execution
In the Connection Wizard, select the Connection Extensibility option, after you have input a name for the Connection.
For the Driver Class, use:
For the JDBC URL, copy in your URL:
Save the connection. You are now ready to write QueryPairs with this Connection.