Class DBFunctions

java.lang.Object
com.iizix.server.db.DBFunctions

public class DBFunctions extends Object
Database functions are placed in this class.
Author:
Christopher Mindus
  • Method Details

    • getInstance

      public static DBFunctions getInstance() throws SQLException
      Gets the DBFunctions instance.
      Returns:
      The DBFunctions instance.
      Throws:
      SQLException - For connection, class loader or instantiation failures.
      SecurityException - When access is denied.
    • execute

      public static <RESULT> RESULT execute(DBOperation<RESULT> op) throws SQLException, NotFoundException
      Executes a method using a functional interface using an new pooled database connection, closed before returning from this method.
      Type Parameters:
      RESULT - The return value.
      Returns:
      The result.
      Throws:
      NotFoundException - When searched element is not found.
      SQLException - For SQL errors in getting the Connection as well as executing the SQL.
    • execute

      public static <RESULT> RESULT execute(Connection conn, DBOperation<RESULT> op) throws SQLException, NotFoundException
      Executes a method using a functional interface using an existing connection.
      Type Parameters:
      RESULT - The return value.
      Parameters:
      conn - The connection, or null to get a new connection and close it before returning.
      Returns:
      The result.
      Throws:
      NotFoundException - When searched element is not found.
      SQLException - For SQL errors in getting the Connection as well as executing the SQL.
    • getAppID

      public static long getAppID(String appNameID) throws NotFoundException, SQLException
      Gets the unique App ID from an application name ID string.
      Parameters:
      appNameID - The Application name ID ('app_name_id' column in table IZS.APPS).
      Returns:
      The unique App ID.
      Throws:
      NotFoundException - If the Application name ID is not found.
      SQLException - If a database errors occurs.
    • getAppID

      public static long getAppID(Connection conn, String appNameID) throws NotFoundException, SQLException
      Gets the unique App ID from an application name ID string.
      Parameters:
      conn - The database connection, null to get a new one.
      appNameID - The Application name ID ('app_name_id' column in table IZS.APPS).
      Returns:
      The unique App ID.
      Throws:
      NotFoundException - If the Application name ID is not found.
      SQLException - If a database errors occurs.
    • getEnabledApps

      public static DBApp[] getEnabledApps(Set<String> ignoreAppIDs) throws SQLException
      Gets all enabled apps from the database. If an app should be loaded from the database and it fails, this method will log this as a severe error and not return that app entry in the array.
      Parameters:
      ignoreAppIDs - Application IDs to ignore because they have been loaded from command line parameters of the server, effectively overriding database definition
      Throws:
      SQLException - If a database errors occurs.