Package ru.bgcrm.util.sql
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.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final int
static final int
static final int
static final int
-
Constructor Summary
ModifierConstructorDescriptionprotected
ConnectionSet
(Connection master) ConnectionSet
(ConnectionPool setup, boolean autoCommit) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes all the connectionsvoid
commit()
Commits all the connectionsProvides 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.void
recycle()
Deprecated.void
rollback()
Rolls back all the 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:
-
-
Constructor Details
-
ConnectionSet
-
ConnectionSet
-
-
Method Details
-
getConnection
Provides master DB connection to the main database.- Returns:
-
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
Commits all the connections- Throws:
SQLException
-
rollback
public void rollback()Rolls back all the connections -
close
public void close()Closes all the connections- Specified by:
close
in interfaceAutoCloseable
-
recycle
Deprecated.Useclose()
-