Class HSQLListReader


public class HSQLListReader extends AbstractListReader
Writes a list or map of values (see AbstractListReader) as one row into a database table; the table is created from the column definitions if it does not exist.
Author:
Andreas Enders
  • Constructor Details

    • HSQLListReader

      public HSQLListReader(Object aSource, org.jdom2.Element aConfigData, Connection aConnection, String aTableName, FWObservable aObservable)
      Parameters:
      aSource - the values: a map (column name to value) or a collection (in column order)
      aConfigData - the column definitions
      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). A positive result is cached, as this is called for every row (before, the whole table was selected again for every row and the statements were not closed).
      Returns:
      true if the table exists
    • createTable

      protected void createTable(Vector<ColumnData> aColumnDatas) throws SQLException
      Creates new table in the database. The name of table depends on file from which will be the data loaded. Errors executing the statement are logged.
      Parameters:
      aColumnDatas - the column definitions
      Throws:
      SQLException - if the statement cannot be created or closed
    • 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 _, pure numbers prefixed with CLMN_
    • processList

      protected void processList(String aOrientation) throws Exception
      Inserts the values of the source as one row (creating the table first if necessary). Missing numeric values are stored as 0, missing strings as empty string, missing dates as NULL. Errors inserting the row are logged.
      Specified by:
      processList in class AbstractListReader
      Parameters:
      aOrientation - orientation of the data (not used)
      Throws:
      Exception - if a value cannot be converted or the statement cannot be prepared