Package com.iizix.server.db
Class DBFunctions
java.lang.Object
com.iizix.server.db.DBFunctions
Database functions are placed in this class.
- Author:
- Christopher Mindus
Method Summary
Modifier and TypeMethodDescriptionstatic <RESULT> RESULT
execute
(DBOperation<RESULT> op) Executes a method using a functional interface using an new pooled database connection, closed before returning from this method.static <RESULT> RESULT
execute
(Connection conn, DBOperation<RESULT> op) Executes a method using a functional interface using an existing connection.static long
Gets the unique App ID from an application name ID string.static long
getAppID
(Connection conn, String appNameID) Gets the unique App ID from an application name ID string.static DBApp[]
getEnabledApps
(Set<String> ignoreAppIDs) Gets all enabled apps from the database.static DBFunctions
Gets the DBFunctions instance.
Method Details
getInstance
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, ornull
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
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 theApplication 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 theApplication name ID
is not found.SQLException
- If a database errors occurs.
getEnabledApps
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.