Class IndexBuilder


  • public class IndexBuilder
    extends SQLBuilder
    A builder class for creating a CREATE sql statement to create a new table index.
    Since:
    1.4.0
    • Constructor Detail

      • IndexBuilder

        public IndexBuilder()
    • Method Detail

      • CREATE

        public IndexBuilder CREATE​(java.lang.String indexName,
                                   java.lang.String tableName,
                                   Database db)
                            throws java.sql.SQLException
        Generates sql code for creation of a table index.
        Parameters:
        indexName - the name of the index to create
        tableName - the table name
        db - the database object for database type checking
        Returns:
        the instance of the builder to continue building
        Throws:
        java.sql.SQLException - if a database access error occurs
        java.lang.IllegalStateException - if this is not the first method called
      • CREATE_UNIQUE

        public IndexBuilder CREATE_UNIQUE​(java.lang.String indexName,
                                          java.lang.String tableName,
                                          Database db)
                                   throws java.sql.SQLException
        Generates sql code for creation of a table unique index.
        Parameters:
        indexName - the name of the index to create
        tableName - the table name
        db - the database object for database type checking
        Returns:
        the instance of the builder to continue building
        Throws:
        java.lang.IllegalStateException - if this is not the first method called
        java.sql.SQLException - if a database access error occurs
      • addColumn

        public IndexBuilder addColumn​(java.lang.String... columnNames)
        Adds a column to the table using a sql string.
        Parameters:
        columnNames - the names of the columns to add
        Returns:
        the instance of the builder to continue building
        Throws:
        java.lang.IllegalStateException - if a CREATE statement is not called first
      • build

        public TypedStatement build​(Database db)
                             throws java.sql.SQLException
        Runs buildPreparedStatement and passes this object to a new instance of TypedStatement.
        Specified by:
        build in class SQLBuilder
        Parameters:
        db - the database to request the PreparedStatement object from
        Returns:
        a new instance of TypedStatement
        Throws:
        java.sql.SQLException - if a database access error occurs
      • build

        public TypedStatement build()
                             throws java.sql.SQLException
        Runs buildPreparedStatement and passes this object to a new instance of TypedStatement.
        Returns:
        a new instance of TypedStatement
        Throws:
        java.sql.SQLException - if a database access error occurs
      • buildAndCreate

        public boolean buildAndCreate()
                               throws java.sql.SQLException
        Runs buildPreparedStatement, executes the statement and returns true if no errors occurred.
        Returns:
        the result of the statement as a boolean, true if no errors occurred
        Throws:
        java.sql.SQLException - if a database access error occurs