Class DBCommonOperations


  • public class DBCommonOperations
    extends Object
    Author:
    iris.dimni
    • Constructor Detail

      • DBCommonOperations

        public DBCommonOperations()
    • Method Detail

      • createSingleColumnIndexIfNotExist

        protected static void createSingleColumnIndexIfNotExist​(Connection conn,
                                                                String tableName,
                                                                String column)
        CREATE single column generic index for table
        Parameters:
        conn -
        tableName -
        column -
      • createSingleColumnIndexASCIfNotExist

        protected static void createSingleColumnIndexASCIfNotExist​(Connection conn,
                                                                   String tableName,
                                                                   String column)
      • createSingleColumnIndexDESCIfNotExist

        protected static void createSingleColumnIndexDESCIfNotExist​(Connection conn,
                                                                    String tableName,
                                                                    String column)
      • truncateTable

        protected static void truncateTable​(Connection conn,
                                            String table)
        does a truncate of the indicated table
        Parameters:
        conn -
        table -
      • getTableRows

        protected static int getTableRows​(Connection conn,
                                          Statement stm,
                                          String table)
        Returns the number of rows of a given table
        Parameters:
        conn -
        stm -
        table -
        Returns:
      • createTableIndexIfNoneExist

        protected static void createTableIndexIfNoneExist​(Connection conn,
                                                          String tableName,
                                                          String column)
        duplicate code replace with create single column index
        Parameters:
        conn -
        tableName -
        column -
      • createTableIndexIfNoneExist

        protected static void createTableIndexIfNoneExist​(Connection conn,
                                                          Statement statement,
                                                          String tableName,
                                                          String column)
        duplicate code replace with create single column index
        Parameters:
        conn -
        statement -
        tableName -
        column -
      • selectFromTable

        protected static ResultSet selectFromTable​(Connection conn,
                                                   String table,
                                                   String column,
                                                   String value)
        generic select
        Parameters:
        conn -
        table -
        column -
        value -
        Returns:
      • countElementExistHS

        protected static int countElementExistHS​(Connection conn,
                                                 String table,
                                                 String column,
                                                 String value)
                                          throws SQLException
        Counter function LIMITED to 1 max. Used for checking existence.
        Parameters:
        conn -
        table -
        column -
        value -
        Returns:
        1 if at least 1 elemnt matcing serch criteria is found. 0 otherwise
        Throws:
        SQLException
      • moveToTemporaryTable

        protected static void moveToTemporaryTable​(Connection conn,
                                                   String table)
                                            throws SQLException
        clone existing table to temporary one and create a new empty idetical table in place of the moved one
        Parameters:
        conn -
        table -
        Throws:
        SQLException
      • restoreFromTemporaryTable

        protected static void restoreFromTemporaryTable​(Connection conn,
                                                        String table)
                                                 throws SQLException
        drop current table table an move older table in place. Must be called after moveToTemporaryTable
        Parameters:
        conn -
        table -
        Throws:
        SQLException
      • closeStatement

        protected static void closeStatement​(Statement stm)