Class DatabaseOutputAdapter
java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.output.FWSimOutputAdapter
net.simplace.sim.io.output.adapter.DatabaseOutputAdapter
- All Implemented Interfaces:
FWSimFieldContainer
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
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimIOAdapter
FWSimIOAdapter.FREQUENCE -
Field Summary
Fields inherited from class FWSimOutputAdapter
iCacheSize, iQueueFields inherited from class FWSimIOAdapter
iArrayMode, iFieldcount, iFrequence, iHeaderVariables, iInterface, iJexlRule, iKeyMap, iName, iOrderNumber, iProcessTime, iResourceElement, iSession, iSourceKey -
Constructor Summary
ConstructorsConstructorDescriptionDatabaseOutputAdapter(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.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).DatabaseOutputAdapter(FWSimOutputAdapter aOldAdapter, DatabaseInterface aInterface) Copy constructor used when the interface is replaced.DatabaseOutputAdapter(org.jdom2.Element aResourceElement, int aOrderNumber, FWSimVarMap aVarMap) Creates the adapter from anoutputelement. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalize()Returns the connection to the connection pool.protected voidinit(FWSimVarMap aVarMap) Gets a connection and prepares the output table and the insert statement.protected voidwriteData(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.Methods inherited from class FWSimOutputAdapter
createAdapter, createOutputFromObservable, getContentType, getInputVariables, getInterface, getOutputVariables, getQueueLenth, getResetScript, getStatistics, getStatisticsAdapter, getStatisticsHeaderVariables, getStatisticsResultCache, getVarMap, hasStatistics, initialize, isActive, isWriting, receiveData, toHTMLTablestring, toXML, updateAdapter, writeDataMethods inherited from class FWSimIOAdapter
addProcessTime, addVariable, checkCondition, createFormFields, createVariables, getCreateFormXML, getEditFormXML, getFieldMap, getFrequence, getHeaderVariables, getHeaderXML, getJexlRule, getKeyMap, getName, getOrderNumber, getVariable, isArrayMode, isConditionCheck, removeVariable, setFrequenceAndRule, setInterface, setOrderNumber, toString, writeHeaderList
-
Constructor Details
-
DatabaseOutputAdapter
public DatabaseOutputAdapter(org.jdom2.Element aResourceElement, int aOrderNumber, FWSimVarMap aVarMap) Creates the adapter from anoutputelement.- Parameters:
aResourceElement- theoutputelementaOrderNumber- order number of the adapteraVarMap- 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 adapteraFrequence- frequency of the outputaDriver- JDBC driver classaURL- JDBC URLaUser- database useraPass- passwordaCacheSize- capacity of the queueaProcessTime- runtime statistics of the adapteraSession- the session
-
DatabaseOutputAdapter
Copy constructor used when the interface is replaced.- Parameters:
aOldAdapter- the adapter to copyaInterface- 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 adapteraFrequence- frequency of the outputaCacheSize- capacity of the queue
-
-
Method Details
-
init
Gets a connection and prepares the output table and the insert statement. Errors are logged.- Specified by:
initin classFWSimOutputAdapter- Parameters:
aVarMap- variable map used for replacing tokens
-
writeData
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:
writeDatain classFWSimOutputAdapter- Parameters:
aObjectToWrite- the output line- See Also:
-
finalize
Returns the connection to the connection pool.- Overrides:
finalizein classFWSimIOAdapter- Throws:
Exception- if returning the connection fails- See Also:
-