Class DBFunctions


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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      <RESULT> RESULTexecute​(DBOperation<RESULT> op)
      Executes a method using a functional interface, grabbing a connection from the connection pool.
      <RESULT> RESULTexecute​(java.sql.Connection conn, DBOperation<RESULT> op)
      Executes a method using a functional interface using a connection.
      <RESULT,​PARAM>
      RESULT
      execute​(java.sql.Connection conn, PARAM param, DBOperationParam<RESULT,​PARAM> op)
      Executes a method using a functional interface using a connection.
      <RESULT,​PARAM>
      RESULT
      execute​(PARAM param, DBOperationParam<RESULT,​PARAM> op)
      Executes a method using a functional interface, grabbing a connection from the connection pool.
      static DBFunctionsgetInstance()
      Gets the DBFunctions instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

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

        public <RESULT> RESULT execute​(java.sql.Connection conn,
                                       DBOperation<RESULT> op)
                                throws java.sql.SQLException,
                                       NotFoundException
        Executes a method using a functional interface using a connection.
        Type Parameters:
        RESULT - The return value.
        Parameters:
        conn - The connection.
        Returns:
        The result.
        Throws:
        NotFoundException - When searched element is not found.
        java.sql.SQLException - For SQL errors in getting the Connection as well as executing the SQL.
        java.lang.ClassCastException - When parameters are not well defined.
      • execute

        public <RESULT,​PARAM> RESULT execute​(java.sql.Connection conn,
                                                   PARAM param,
                                                   DBOperationParam<RESULT,​PARAM> op)
                                            throws java.sql.SQLException,
                                                   NotFoundException
        Executes a method using a functional interface using a connection.
        Type Parameters:
        PARAM - The parameter for the database operation.
        RESULT - The return value.
        Parameters:
        conn - The connection.
        param - The parameter.
        Returns:
        The result.
        Throws:
        NotFoundException - When searched element is not found.
        java.sql.SQLException - For SQL errors in getting the Connection as well as executing the SQL.
        java.lang.ClassCastException - When parameters are not well defined.
      • execute

        public <RESULT> RESULT execute​(DBOperation<RESULT> op)
                                throws java.sql.SQLException,
                                       NotFoundException
        Executes a method using a functional interface, grabbing a connection from the connection pool.
        Type Parameters:
        RESULT - The return value.
        Returns:
        The result.
        Throws:
        NotFoundException - When searched element is not found.
        java.sql.SQLException - For SQL errors in getting the Connection as well as executing the SQL.
        java.lang.ClassCastException - When parameters are not well defined.
      • execute

        public <RESULT,​PARAM> RESULT execute​(PARAM param,
                                                   DBOperationParam<RESULT,​PARAM> op)
                                            throws java.sql.SQLException,
                                                   NotFoundException
        Executes a method using a functional interface, grabbing a connection from the connection pool.
        Type Parameters:
        PARAM - The parameter for the database operation.
        RESULT - The return value.
        Parameters:
        param - The parameter.
        Returns:
        The result.
        Throws:
        NotFoundException - When searched element is not found.
        java.sql.SQLException - For SQL errors in getting the Connection as well as executing the SQL.
        java.lang.ClassCastException - When parameters are not well defined.