java.lang.Object
uk.ac.manchester.spinnaker.alloc.db.Utils

public abstract class Utils
extends Object
Miscellaneous database-related utility operations.
Author:
Donal Fellows
  • Method Details

    • trimSQL

      public static String trimSQL​(String sql)
      Exclude comments and compress whitespace from the SQL of a statement.
      Parameters:
      sql - The text of the SQL to trim.
      Returns:
      The trimmed SQL.
    • trimSQL

      public static String trimSQL​(String sql, int length)
      Exclude comments and compress whitespace from the SQL of a statement.
      Parameters:
      sql - The text of the SQL to trim.
      length - The point to insert an ellipsis if required.
      Returns:
      The trimmed SQL.
    • isBusy

      public static boolean isBusy​(DataAccessException exception)
      Utility for testing whether an exception was thrown because the database was busy.
      Parameters:
      exception - The outer wrapping exception.
      Returns:
      Whether it was caused by the database being busy.
    • isBusy

      public static boolean isBusy​(SQLException exception)
      Utility for testing whether an exception was thrown because the database was busy.
      Parameters:
      exception - The exception to test.
      Returns:
      Whether it was caused by the database being busy.
    • mapException

      public static DataAccessException mapException​(SQLException exception, String sql)
      Convert an SQL-related exception into an unchecked exception.
      Parameters:
      exception - The exception to convert.
      sql - Optional SQL that caused the problem. May be null.
      Returns:
      The converted exception; this is not thrown by this method!