Package edu.wisc.library.ocfl.core.db
Class PostgresObjectDetailsDatabase
- java.lang.Object
-
- edu.wisc.library.ocfl.core.db.BaseObjectDetailsDatabase
-
- edu.wisc.library.ocfl.core.db.PostgresObjectDetailsDatabase
-
- All Implemented Interfaces:
ObjectDetailsDatabase
public class PostgresObjectDetailsDatabase extends BaseObjectDetailsDatabase
-
-
Constructor Summary
Constructors Constructor Description PostgresObjectDetailsDatabase(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.-
Methods inherited from class edu.wisc.library.ocfl.core.db.BaseObjectDetailsDatabase
addObjectDetails, deleteAllDetails, deleteAllQuery, deleteDetailsQuery, deleteObjectDetails, insertDetailsQuery, retrieveObjectDetails, rowLockQuery, selectDetailsQuery, selectDigestQuery, updateDetailsQuery, updateObjectDetails
-
-
-
-
Constructor Detail
-
PostgresObjectDetailsDatabase
public PostgresObjectDetailsDatabase(String tableName, DataSource dataSource, boolean storeInventory, long waitTime, TimeUnit timeUnit)
-
-
Method Detail
-
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
-
-