Class IndexBuilder
- java.lang.Object
-
- com.jgcomptech.tools.databasetools.jdbc.builders.SQLBuilder
-
- com.jgcomptech.tools.databasetools.jdbc.builders.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 Summary
Constructors Constructor Description IndexBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexBuilder
addColumn(java.lang.String... columnNames)
Adds a column to the table using a sql string.TypedStatement
build()
Runs buildPreparedStatement and passes this object to a new instance ofTypedStatement
.TypedStatement
build(Database db)
Runs buildPreparedStatement and passes this object to a new instance ofTypedStatement
.boolean
buildAndCreate()
Runs buildPreparedStatement, executes the statement and returns true if no errors occurred.IndexBuilder
CREATE(java.lang.String indexName, java.lang.String tableName, Database db)
Generates sql code for creation of a table index.IndexBuilder
CREATE_UNIQUE(java.lang.String indexName, java.lang.String tableName, Database db)
Generates sql code for creation of a table unique index.-
Methods inherited from class com.jgcomptech.tools.databasetools.jdbc.builders.SQLBuilder
buildPreparedStatement, getSql, getStatement, setStatement, toString
-
-
-
-
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 createtableName
- the table namedb
- 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 occursjava.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 createtableName
- the table namedb
- 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 calledjava.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 ofTypedStatement
.- Specified by:
build
in classSQLBuilder
- Parameters:
db
- the database to request thePreparedStatement
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 ofTypedStatement
.- 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
-
-