Package io.ocfl.core.db
Class MariaDbObjectDetailsDatabase
java.lang.Object
io.ocfl.core.db.BaseObjectDetailsDatabase
io.ocfl.core.db.MariaDbObjectDetailsDatabase
- All Implemented Interfaces:
ObjectDetailsDatabase
-
Constructor Summary
ConstructorsConstructorDescriptionMariaDbObjectDetailsDatabase
(String tableName, DataSource dataSource, boolean storeInventory, long waitTime, TimeUnit timeUnit) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
isConcurrentWriteException
(SQLException exception) Checks if given exception was thrown because of concurrent write issue or something else.protected void
setLockWaitTimeout
(Connection connection, long waitMillis) Sets the amount of time to wait for a row lock before timing out.protected String
updateDetailsQuery
(String tableName) Constructs the query for updating object details entriesMethods inherited from class io.ocfl.core.db.BaseObjectDetailsDatabase
addObjectDetails, deleteAllDetails, deleteAllQuery, deleteDetailsQuery, deleteObjectDetails, insertDetailsQuery, retrieveObjectDetails, rowLockQuery, selectDetailsQuery, selectDigestQuery, updateObjectDetails
-
Constructor Details
-
MariaDbObjectDetailsDatabase
public MariaDbObjectDetailsDatabase(String tableName, DataSource dataSource, boolean storeInventory, long waitTime, TimeUnit timeUnit)
-
-
Method Details
-
updateDetailsQuery
Description copied from class:BaseObjectDetailsDatabase
Constructs the query for updating object details entries- Overrides:
updateDetailsQuery
in classBaseObjectDetailsDatabase
- Parameters:
tableName
- the name of the object details table- Returns:
- the query string
-
setLockWaitTimeout
Sets the amount of time to wait for a row lock before timing out. Keep in mind that MariaDB actually uses seconds for timeout, make sure that you use at least 1000ms as input to the method and go up in 1 second increments.- Specified by:
setLockWaitTimeout
in classBaseObjectDetailsDatabase
- Parameters:
connection
- db connectionwaitMillis
- time to wait for the lock in millis- Throws:
SQLException
- on sql error
-
isConcurrentWriteException
Checks if given exception was thrown because of concurrent write issue or something else. Check is performed by getting the SQL State Code from exception, but since each driver and vendor uses their own codes, or even several codes this check needs to be driver specific. H2 for example throws a "duplicate key" state code, while MariaDB can throw either "deadlock" or "duplicate key" state codes.- Specified by:
isConcurrentWriteException
in classBaseObjectDetailsDatabase
- Parameters:
exception
- instance of an SQLException class to check- Returns:
- true if exception occurred because of concurrent write, false for any other exception
-