public abstract class AbstractBatcher extends java.lang.Object implements Batcher
DbControl
object. It implements all methods in the
Batcher
interface except the Batcher.flush()
method.
A subclass may also have to override the close()
method
if it has opened connections or statements to the database.
Modifier and Type | Field and Description |
---|---|
private int |
batchSize
SQL command batch size.
|
private java.lang.ref.WeakReference<DbControl> |
dc
A reference to the current DbControl object.
|
protected static boolean |
debugSqlEnabled
So we don't always have to call logSql.debug()
|
protected static org.slf4j.Logger |
logSql
Log all SQL statements.
|
private SessionControl |
sc |
Constructor and Description |
---|
AbstractBatcher()
Constructor for a batcher.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
analyzeTable(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Update index statistics for a table.
|
void |
close()
Flush the batcher and close it.
|
int |
getBatchSize()
Get the current batch size of the batcher.
|
DbControl |
getDbControl()
Get the
DbControl object that currently manages this batcher. |
SessionControl |
getSessionControl()
Get the
SessionControl object that manages this item. |
boolean |
isClosed()
Check if this batcher is closed or not.
|
(package private) void |
onBeforeClose()
Let a subclass cleanup itself before the connection to
the database is closed.
|
void |
setBatchSize(int batchSize)
Sets the batch size.
|
protected void |
setDbControl(DbControl dc)
Set the DbControl that is controlling this batcher.
|
(package private) void |
updateLastAccess()
Update the last access time so the session control doesn't
get cleaned up.
|
protected static final org.slf4j.Logger logSql
protected static final boolean debugSqlEnabled
private SessionControl sc
private java.lang.ref.WeakReference<DbControl> dc
private int batchSize
AbstractBatcher()
BaseException
- If there is an errorpublic int getBatchSize()
Batcher
getBatchSize
in interface Batcher
public void setBatchSize(int batchSize)
Batcher
setBatchSize
in interface Batcher
batchSize
- Size of the batch, or 0 to disable automatic flushingpublic final boolean isClosed()
DbControl
or if the DbControl
it is attached to has been closed.isClosed
in interface Batcher
Batcher.close()
public final void close() throws BaseException
Batcher
DbControl
to connect to the database
will automatically be closed when the DbControl
is closed.close
in interface Batcher
BaseException
- If there is an errorBatcher.isClosed()
,
Batcher.flush()
void updateLastAccess()
protected final void setDbControl(DbControl dc)
DbControl.addBatcher(Batcher)
public final DbControl getDbControl() throws ConnectionClosedException
DbControl
object that currently manages this batcher.ConnectionClosedException
- If the batcher is connected to a closed
DbControl
object, or not connected at allpublic final SessionControl getSessionControl() throws ConnectionClosedException
SessionControl
object that manages this item.ConnectionClosedException
- If the item is connected to a closed
DbControl
object, or not connected at allvoid onBeforeClose() throws BaseException
close()
method after Batcher.flush()
has been called but before the connection
to the database is lost. Typical use of this method is to update
properties on parent object (for example, spot count) and to close
open SQL statements.BaseException
void analyzeTable(java.lang.String catalog, java.lang.String schema, java.lang.String table)