Class HSQLListReader
java.lang.Object
net.simplace.core.io.AbstractDataReader
net.simplace.core.io.AbstractListReader
net.simplace.core.database.HSQLListReader
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
-
Field Summary
Fields inherited from class AbstractListReader
iSourceFields inherited from class AbstractDataReader
iColumnsData, iConfigData, iObservable -
Constructor Summary
ConstructorsConstructorDescriptionHSQLListReader(Object aSource, org.jdom2.Element aConfigData, Connection aConnection, String aTableName, FWObservable aObservable) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateTable(Vector<ColumnData> aColumnDatas) Creates new table in the database.static StringgetCanonicalForm(String aText) booleanChecks if the table exists (by selecting from it).protected voidprocessList(String aOrientation) Inserts the values of the source as one row (creating the table first if necessary).Methods inherited from class AbstractListReader
initColumnHeads, initTitle, readDataMethods inherited from class AbstractDataReader
getIntegerValue
-
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 definitionsaConnection- the database connectionaTableName- name of the target tableaObservable- 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:
trueif the table exists
-
createTable
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
-
processList
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:
processListin classAbstractListReader- Parameters:
aOrientation- orientation of the data (not used)- Throws:
Exception- if a value cannot be converted or the statement cannot be prepared
-