Package de.businesscode.bcdui.logging
Class SqlToDatabaseLogger
java.lang.Object
de.businesscode.bcdui.toolbox.AWorkerQueue<T>
de.businesscode.bcdui.logging.SqlToDatabaseLogger
a singleton logger for SQL statements, the binding set used for it is bcd_log_sql,
record logged is
SqlToDatabaseLogger.LogRecord
this class is not intended to be customized or extended in projects. The existence of
the binding-set enables this logger automatically.
This logger used by BcdConnectionWrapper, so only wrapped JDBC connections log into database,
any connection obtained from Configuration
class provides such a wrapped connection.
If you want to disable logging temporarily, i.e. in case you're in another logger you may
want to use setLoggingEnabled(boolean)
method. Then, the SQLs generated by your code
might be propagated to Log4J logging, but they will not be published to the database. You may
also want to take a look at BcdSqlLogger
class enabling programmatic switching of jdbc
logging.
Additionally this logger currently also logs HTTP layer information, if available, provided
by RequestLifeCycleFilter
, therefore the dependency on that class.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
record being logged into db -
Field Summary
Fields inherited from class de.businesscode.bcdui.toolbox.AWorkerQueue
DEFAULT_MAX_QUEUE_SIZE, log
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object[][]
processes given collection of type to dimensional object array to be consumed by batch SQLprotected int[]
executeStatement
(Object[][] params) executes statement with raw parameters and returns number of updated rowsprotected DataSource
static SqlToDatabaseLogger
protected String
boolean
as SQL logger we are depended on Bindings, which in turn use classes using us, so we dont participate in Binding bootstrap processprotected void
implement the method to process the objects polled from queue (FIFO)void
setEnabled
(boolean isEnabled) enables/disables JDBC logging for this thread, this method has to be called prior creating a JDBC statement (or connection, datasource), if you dont obtain DataSource or Connection object fromConfiguration
class, you dont need to use this method, as those Connections are not logged anyway.static void
setLoggingEnabled
(boolean isEnabled) a shortcut togetInstance().setEnabled()
Methods inherited from class de.businesscode.bcdui.toolbox.AWorkerQueue
enqueue, onIdle, process, process, shutdownQueues
-
Constructor Details
-
SqlToDatabaseLogger
protected SqlToDatabaseLogger()
-
-
Method Details
-
isEnabled
public boolean isEnabled()as SQL logger we are depended on Bindings, which in turn use classes using us, so we dont participate in Binding bootstrap process- Returns:
-
setEnabled
public void setEnabled(boolean isEnabled) enables/disables JDBC logging for this thread, this method has to be called prior creating a JDBC statement (or connection, datasource), if you dont obtain DataSource or Connection object fromConfiguration
class, you dont need to use this method, as those Connections are not logged anyway. sample usage:try{ SqlToDatabaseLogger.setLoggingEnabled(false); ;; // obtain and work with JDBC statement here }finally{ SqlToDatabaseLogger.setLoggingEnabled(true); }
- Parameters:
isEnabled
-
-
setLoggingEnabled
public static void setLoggingEnabled(boolean isEnabled) a shortcut togetInstance().setEnabled()
- Parameters:
isEnabled
-
-
getInstance
-
getSqlTemplate
- Returns:
- SQL template for inserts (prepared statement compatible to process batch updates) this sql template is not intended to change and is cached so this function is called only once
-
convertData
processes given collection of type to dimensional object array to be consumed by batch SQL- Parameters:
records
-- Returns:
-
processObjects
Description copied from class:AWorkerQueue
implement the method to process the objects polled from queue (FIFO)- Specified by:
processObjects
in classAWorkerQueue<T>
- Parameters:
records
- to process
-
executeStatement
executes statement with raw parameters and returns number of updated rows- Parameters:
params
-- Returns:
- The number of rows updated per statement
- Throws:
SQLException
-
getDataSource
- Returns:
- a datasource as referenced by the binding-set or the default datasource
- Throws:
RuntimeException
- in case datasource name discovery via Bindings takes place whilst Bindings has not initialized yet.
-