DefaultDBOutputter. CachedJdbcAppender extends JDBCAppender
and uses most of the functionality. To enable chaching,
DefaultDBOutputter. CachedJdbcAppender overwrites
JDBCAppender#execute() and stores all sql statements into a buffer
until the limit is reached. Furthermore, it adds the column definitions
as the first part of SQL statement. To flush the buffer on close(),
DefaultDBOutputter. CachedJdbcAppender also overwrites
JDBCAppender#close() and directly calls JDBCAppender#execute()
to by-pass caching.
Overwriting JDBCAppender#getLogStatement() is used to generate the
SQL peace for every column defined in the DbOutputterDescriptor.
CachedJdbcAppender and also adds the runID if activated.
To ensure all cache is sent to the database, the
DbOutputterDescriptor. CachedJdbcAppender’s close() method
is scheduled at the last tick with priority ScheduleParameters.
LAST_PRIORITY. Otherwise, close() is not called before the
simualtion is reset, and in case the user closes the application without
resetting the cached data is missed.
The plugin does not throw SQLExceptions in order not to interrupt
simulations because of output errors. Instead, a ERROR-Logging to the
Repast Simphony Message Center is triggered.
Since Repast Simphony 2.0.0, initialisation of data outputters take
place not before the first data is logged. Therefore, calls to
DefaultDBOutputter.getCurrentMaxRunId() before the first data is
logged cannot access any information required to connect to the
database. That’s why
DefaultDBOutputter.getCurrentMaxRunId(runInfoTable, dbConInfo) was
added.