Class Utils
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 Summary
Modifier and Type Method Description static boolean
isBusy(SQLException exception)
Utility for testing whether an exception was thrown because the database was busy.static boolean
isBusy(DataAccessException exception)
Utility for testing whether an exception was thrown because the database was busy.static DataAccessException
mapException(SQLException exception, String sql)
Convert an SQL-related exception into an unchecked exception.static String
trimSQL(String sql)
Exclude comments and compress whitespace from the SQL of a statement.static String
trimSQL(String sql, int length)
Exclude comments and compress whitespace from the SQL of a statement.
-
Method Details
-
trimSQL
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
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
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
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
Convert an SQL-related exception into an unchecked exception.- Parameters:
exception
- The exception to convert.sql
- Optional SQL that caused the problem. May benull
.- Returns:
- The converted exception; this is not thrown by this method!
-