Package ru.bgcrm.util.sql
Class ConnectionSet
java.lang.Object
ru.bgcrm.util.sql.ConnectionSet
- Direct Known Subclasses:
SingleConnectionSet
Set with DB connections, taken from pools on demand.
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
static final String
static final int
static final int
static final int
static final int
-
Constructor Summary
ModifierConstructorDescriptionprotected
ConnectionSet
(Connection master) protected
ConnectionSet
(Connection master, boolean autoCommit) ConnectionSet
(ConnectionPool setup, boolean autoCommit) -
Method Summary
Modifier and TypeMethodDescriptionvoid
commit()
boolean
Provides master DB connection to the main database.Gets slave connection to read-only DB replica.getTrashConnection
(String tableName, int defaultType) Gets connection to so-called 'trash' DB, containing non-critical data.protected Connection
protected Connection
protected Connection
newTrashConnection
(String tableName) void
recycle()
void
rollback()
void
setAutoCommit
(boolean autoCommit) Sets autocommit property to all connections.
-
Field Details
-
KEY
- See Also:
-
TYPE_MASTER
public static final int TYPE_MASTER- See Also:
-
TYPE_SLAVE
public static final int TYPE_SLAVE- See Also:
-
TYPE_TRASH
public static final int TYPE_TRASH- See Also:
-
TYPE_FAKE
public static final int TYPE_FAKE- See Also:
-
autoCommit
protected boolean autoCommit
-
-
Constructor Details
-
ConnectionSet
-
ConnectionSet
-
ConnectionSet
-
-
Method Details
-
getConnection
Provides master DB connection to the main database.- Returns:
-
newMasterConnection
-
newSlaveConnection
-
newTrashConnection
-
getSlaveConnection
Gets slave connection to read-only DB replica.- Returns:
-
getTrashConnection
Gets connection to so-called 'trash' DB, containing non-critical data.- Parameters:
tableName
- table name.defaultType
- DB type returned if no trash DB is configured, can be:TYPE_SLAVE
- slave DB connection;TYPE_FAKE
- instance ofFakeConnection
, does not do anything;TYPE_MASTER
- master DB connection.- Returns:
-
commit
- Throws:
Exception
-
recycle
public void recycle() -
getAutoCommit
public boolean getAutoCommit() -
setAutoCommit
public void setAutoCommit(boolean autoCommit) Sets autocommit property to all connections.- Parameters:
autoCommit
- wanted value.
-
rollback
public void rollback()
-