Package edu.wisc.library.ocfl.core.db
Class MariaDbObjectDetailsDatabase
- java.lang.Object
-
- edu.wisc.library.ocfl.core.db.BaseObjectDetailsDatabase
-
- edu.wisc.library.ocfl.core.db.MariaDbObjectDetailsDatabase
-
- All Implemented Interfaces:
ObjectDetailsDatabase
public class MariaDbObjectDetailsDatabase extends BaseObjectDetailsDatabase
-
-
Constructor Summary
Constructors Constructor Description MariaDbObjectDetailsDatabase(String tableName, DataSource dataSource, boolean storeInventory, long waitTime, TimeUnit timeUnit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanisConcurrentWriteException(SQLException exception)Checks if given exception was thrown because of concurrent write issue or something else.protected voidsetLockWaitTimeout(Connection connection, long waitMillis)Sets the amount of time to wait for a row lock before timing out.protected StringupdateDetailsQuery(String tableName)Constructs the query for updating object details entries-
Methods inherited from class edu.wisc.library.ocfl.core.db.BaseObjectDetailsDatabase
addObjectDetails, deleteAllDetails, deleteAllQuery, deleteDetailsQuery, deleteObjectDetails, insertDetailsQuery, retrieveObjectDetails, rowLockQuery, selectDetailsQuery, selectDigestQuery, updateObjectDetails
-
-
-
-
Constructor Detail
-
MariaDbObjectDetailsDatabase
public MariaDbObjectDetailsDatabase(String tableName, DataSource dataSource, boolean storeInventory, long waitTime, TimeUnit timeUnit)
-
-
Method Detail
-
updateDetailsQuery
protected String updateDetailsQuery(String tableName)
Description copied from class:BaseObjectDetailsDatabaseConstructs the query for updating object details entries- Overrides:
updateDetailsQueryin classBaseObjectDetailsDatabase- Parameters:
tableName- the name of the object details table- Returns:
- the query string
-
setLockWaitTimeout
protected void setLockWaitTimeout(Connection connection, long waitMillis) throws SQLException
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:
setLockWaitTimeoutin classBaseObjectDetailsDatabase- Parameters:
connection- db connectionwaitMillis- time to wait for the lock in millis- Throws:
SQLException- on sql error
-
isConcurrentWriteException
protected boolean isConcurrentWriteException(SQLException exception)
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:
isConcurrentWriteExceptionin classBaseObjectDetailsDatabase- Parameters:
exception- instance of an SQLException class to check- Returns:
- true if exception occurred because of concurrent write, false for any other exception
-
-