Class HSQLAsciiReader


public class HSQLAsciiReader extends AbstractAsciiReader
Reads a fixed-width or separated ASCII file (see AbstractAsciiReader) into a database table; the table is created from the column definitions if it does not exist.
  • Constructor Details

    • HSQLAsciiReader

      public HSQLAsciiReader(File aSourceFile, org.jdom2.Element aConfigData, String aTabLen, String aSeperator, String aDefaultDateFormat, Connection aConnection, String aTableName, FWObservable aObservable)
      Parameters:
      aSourceFile - the ASCII file
      aConfigData - the column definitions
      aTabLen - tab length (for fixed-width files)
      aSeperator - column separator
      aDefaultDateFormat - default date format
      aConnection - the database connection
      aTableName - name of the target table
      aObservable - provides the parameters
  • Method Details

    • isTableCreated

      public boolean isTableCreated()
      Checks if the table exists (by selecting from it).
      Returns:
      true if the table exists
    • createTable

      public static void createTable(Connection aConnection, String aTableName, Vector<ColumnData> aColumnDatas, boolean aDropBeforeDelete)
      Creates new table in the database with one column per column definition (sorted by column index; dots in names become __, array types become VARCHAR(10000), DOUBLE becomes DOUBLE PRECISION). Errors are logged.
      Parameters:
      aConnection - the database connection
      aTableName - name of the table
      aColumnDatas - the column definitions (sorted in place)
      aDropBeforeDelete - true to drop an existing table first
    • getCanonicalForm

      public static String getCanonicalForm(String aText)
      Parameters:
      aText - a name
      Returns:
      string which can be used for table name, column name, ... in a database (dots replaced by __)
    • processLineOfFile

      protected void processLineOfFile(String aOrientation, String aLine, int aRowIdx) throws Exception
      Inserts one line of the file as row (creating the table first if necessary). Values that cannot be parsed are logged and inserted as NULL; errors inserting the row are logged.
      Specified by:
      processLineOfFile in class AbstractAsciiReader
      Parameters:
      aOrientation - orientation of the data (not used)
      aLine - the line
      aRowIdx - index of the line
      Throws:
      Exception - if the insert statement cannot be prepared