Class PostgresObjectDetailsDatabase

java.lang.Object
io.ocfl.core.db.BaseObjectDetailsDatabase
io.ocfl.core.db.PostgresObjectDetailsDatabase
All Implemented Interfaces:
ObjectDetailsDatabase

public class PostgresObjectDetailsDatabase extends BaseObjectDetailsDatabase
  • Constructor Details

    • PostgresObjectDetailsDatabase

      public PostgresObjectDetailsDatabase(String tableName, DataSource dataSource, boolean storeInventory, long waitTime, TimeUnit timeUnit)
  • Method Details

    • 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:
      setLockWaitTimeout in class BaseObjectDetailsDatabase
      Parameters:
      connection - db connection
      waitMillis - 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:
      isConcurrentWriteException in class BaseObjectDetailsDatabase
      Parameters:
      exception - instance of an SQLException class to check
      Returns:
      true if exception occurred because of concurrent write, false for any other exception