Class ConnectionSet
java.lang.Object
ru.bgcrm.util.sql.ConnectionSet
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
SingleConnectionSet
Set with DB connections, taken from a pool on demand
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConnectionSet(Connection master) ConnectionSet(ConnectionPool setup, boolean autoCommit) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes all the connectionsvoidcommit()Commits all the connectionsstatic ConnectionSetGets a connection set object from a context byKEYProvides master DB connection to the main databaseGets slave connection to read-only DB replicagetTrashConnection(String tableName, int defaultType) Gets connection to so-called 'trash' DB, containing non-critical datavoidrecycle()Deprecated.voidrollback()Rolls back all the connectionsvoidPuts the connection set to a context byKEY
-
Constructor Details
-
ConnectionSet
-
ConnectionSet
-
-
Method Details
-
context
Gets a connection set object from a context byKEY- Parameters:
context- the context- Returns:
- the connection set
-
getConnection
Provides master DB connection to the main database- Returns:
- the master connection
-
getSlaveConnection
Gets slave connection to read-only DB replica- Returns:
- the slave connection
-
getTrashConnection
Gets connection to so-called 'trash' DB, containing non-critical data- Parameters:
tableName- table namedefaultType- 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:
- the connection
-
commit
Commits all the connections- Throws:
SQLException- if a commit fails
-
rollback
public void rollback()Rolls back all the connections -
close
-
toContext
-
recycle
-