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