Package org.eclnt.ccee.db
Class DBCreateTables
java.lang.Object
org.eclnt.ccee.db.DBCreateTables
- All Implemented Interfaces:
ICCEEConstants
Executes a SQL script for creating database artifacts (tables, views, ...).
The main method for execution are
The SQL script is contained in the resource file "ccee_dbcreatetables.sql" for the default context and in the file "ccee_dbcreatetables_<contextName>.txt" for additional contexts.
Database statements are separated by one or several ";" delimiters. Example:
CREATE TABLE xxx ...;
CREATE TABLE yyy ...;
...
The statements of the file are executed one after the next. In case of failing there is some log output - but the script is continued to be executed.
Typical usage: you first define inside "ccee_dbcreatetables.sql" the tables you want to create. After running this class the tables are created. - At a later point of time you decide to append a field to a table definition (ALTER TABLE ... ADD COLUMN ...) or you create a new table (CREATE TABLE ...). When now running this class these statements (e.g. CREATE TABLE for already existing tables) will fail - and only the new statements will be successfully executed.
As result you have a simple but efficient way to update the database structure throughout various application versions in a consistent way.
createTables() and
createTables(String). The SQL script is contained in the resource file "ccee_dbcreatetables.sql" for the default context and in the file "ccee_dbcreatetables_<contextName>.txt" for additional contexts.
Database statements are separated by one or several ";" delimiters. Example:
CREATE TABLE xxx ...;
CREATE TABLE yyy ...;
...
The statements of the file are executed one after the next. In case of failing there is some log output - but the script is continued to be executed.
Typical usage: you first define inside "ccee_dbcreatetables.sql" the tables you want to create. After running this class the tables are created. - At a later point of time you decide to append a field to a table definition (ALTER TABLE ... ADD COLUMN ...) or you create a new table (CREATE TABLE ...). When now running this class these statements (e.g. CREATE TABLE for already existing tables) will fail - and only the new statements will be successfully executed.
As result you have a simple but efficient way to update the database structure throughout various application versions in a consistent way.
-
Field Summary
Fields inherited from interface org.eclnt.ccee.ICCEEConstants
AND, ASC, AVG, BETWEEN, BRC, BRO, COUNT, DEFAULT_CONTEXT, DESC, FUNCTIONRESULT, GREATER, GREATEREQUAL, IN, IS, ISNOT, LIKE, LL_DBG, LL_ERR, LL_INF, LL_WAR, LOWER, LOWEREQUAL, MAX, MIN, NULL, OR, ORDERBY, QPFUNCTION_LOWER, QPFUNCTION_UPPER, SUM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringadaptCreateTablesStatement(String contextName, String sql) booleanCreates the tables in default resource file "ccee_dbcreatetables.sql".booleancreateTables(String contextName) Creates the tables in default resource file "ccee_dbcreatetables.sql" for the DEFAULT_CONTEXT and in "ccee_dbcreatetables_<contextName>.sql" for other contexts.booleancreateTablesByExplicitResourceFile(String resourceName) Create tables according to statements that are contained in the resource that is passed.booleancreateTablesByExplicitResourceFile(String contextName, String resourceName) Create tables according to statements that are contained in the resource that is passed.booleancreateTablesBySqlSequence(String contextName, String allSql) Create tables according to statements that are contained in the String that is passed.booleancreatTablesByExplicitResourceFile(String resourceName) Deprecated.booleancreatTablesByExplicitResourceFile(String contextName, String resourceName) Deprecated.booleanexecute()Internally just callscreateTables().protected voidexecuteStatement(String contextName, String sql) protected voidstatic voidprotected StringremoveComments(String allSql)
-
Constructor Details
-
DBCreateTables
public DBCreateTables()
-
-
Method Details
-
main
-
execute
public boolean execute()Internally just callscreateTables().- Returns:
- true if all statements were executed successful.
-
createTables
public boolean createTables()Creates the tables in default resource file "ccee_dbcreatetables.sql".- Returns:
- true if all statements were executed successful.
-
createTables
Creates the tables in default resource file "ccee_dbcreatetables.sql" for the DEFAULT_CONTEXT and in "ccee_dbcreatetables_<contextName>.sql" for other contexts.- Returns:
- true if all statements were executed successful.
-
createTablesByExplicitResourceFile
Create tables according to statements that are contained in the resource that is passed.- Returns:
- true if all statements were executed successful.
-
creatTablesByExplicitResourceFile
Deprecated. -
createTablesByExplicitResourceFile
Create tables according to statements that are contained in the resource that is passed.- Returns:
- true if all statements were executed successful.
-
creatTablesByExplicitResourceFile
@Deprecated public boolean creatTablesByExplicitResourceFile(String contextName, String resourceName) Deprecated. -
createTablesBySqlSequence
Create tables according to statements that are contained in the String that is passed.- Returns:
- true if all statements were executed successful.
-
removeComments
-
logThrowableWithCauses
-
executeStatement
-
adaptCreateTablesStatement
-