Class DatabaseOutputAdapter

All Implemented Interfaces:
FWSimFieldContainer

public class DatabaseOutputAdapter extends FWSimOutputAdapter
Output adapter writing the output of an FWSimOutput to a database table (DatabaseInterface). The table is prepared on initialization; each output line is inserted with a prepared statement. Arrays are stored as strings.
Author:
Andreas Enders
  • Constructor Details

    • DatabaseOutputAdapter

      public DatabaseOutputAdapter(org.jdom2.Element aResourceElement, int aOrderNumber, FWSimVarMap aVarMap)
      Creates the adapter from an output element.
      Parameters:
      aResourceElement - the output element
      aOrderNumber - order number of the adapter
      aVarMap - template variable map of the solution
    • DatabaseOutputAdapter

      public DatabaseOutputAdapter(String aName, String aName2, int aOrderNumber, FWSimIOAdapter.FREQUENCE aFrequence, String aDriver, String aURL, String aUser, String aPass, String aCacheSize, ProcessTime aProcessTime, FWSimSession aSession)
      Creates the adapter from the graph panel with its own database interface.
      Parameters:
      aName - name of the adapter (and the output table)
      aName2 - name of the interface (connection pool)
      aOrderNumber - order number of the adapter
      aFrequence - frequency of the output
      aDriver - JDBC driver class
      aURL - JDBC URL
      aUser - database user
      aPass - password
      aCacheSize - capacity of the queue
      aProcessTime - runtime statistics of the adapter
      aSession - the session
    • DatabaseOutputAdapter

      public DatabaseOutputAdapter(FWSimOutputAdapter aOldAdapter, DatabaseInterface aInterface)
      Copy constructor used when the interface is replaced.
      Parameters:
      aOldAdapter - the adapter to copy
      aInterface - the new interface
    • DatabaseOutputAdapter

      public DatabaseOutputAdapter(String aName, FWSimVarMap aVarMap, int aOrderNumber, FWSimIOAdapter.FREQUENCE aFrequence, String aCacheSize)
      Creates an adapter writing to the default connection pool of the solution (used for calibration outputs).
      Parameters:
      aName - name of the adapter (and the output table)
      aVarMap - template variable map (provides session and solution)
      aOrderNumber - order number of the adapter
      aFrequence - frequency of the output
      aCacheSize - capacity of the queue
  • Method Details

    • init

      protected void init(FWSimVarMap aVarMap)
      Gets a connection and prepares the output table and the insert statement. Errors are logged.
      Specified by:
      init in class FWSimOutputAdapter
      Parameters:
      aVarMap - variable map used for replacing tokens
    • writeData

      protected void writeData(FWSimQueueObjectMap aObjectToWrite)
      Inserts an output line into the table (in the writer thread): the values are set in the order of the header variables according to their data types; arrays are written as strings, dates as SQL dates. SQL errors and wrong data types are logged.
      Specified by:
      writeData in class FWSimOutputAdapter
      Parameters:
      aObjectToWrite - the output line
      See Also:
    • finalize

      public void finalize() throws Exception
      Returns the connection to the connection pool.
      Overrides:
      finalize in class FWSimIOAdapter
      Throws:
      Exception - if returning the connection fails
      See Also: