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 TypeMethodDescriptionvoid
Creates the tables in default resource file "ccee_dbcreatetables.sql".void
createTables
(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.void
createTablesBySqlSequence
(String contextName, String allSql) void
creatTablesByExplicitResourceFile
(String resourceName) Create tables according to statements that are contained in the resource that is passed.void
creatTablesByExplicitResourceFile
(String contextName, String resourceName) Create tables according to statements that are contained in the resource that is passed.void
execute()
Internally just callscreateTables()
.static void
protected String
removeComments
(String allSql)
-
Constructor Details
-
DBCreateTables
public DBCreateTables()
-
-
Method Details
-
main
-
execute
public void execute()Internally just callscreateTables()
. -
createTables
public void createTables()Creates the tables in default resource file "ccee_dbcreatetables.sql". -
createTables
Creates the tables in default resource file "ccee_dbcreatetables.sql" for the DEFAULT_CONTEXT and in "ccee_dbcreatetables_<contextName>.sql" for other contexts. -
creatTablesByExplicitResourceFile
Create tables according to statements that are contained in the resource that is passed. -
creatTablesByExplicitResourceFile
Create tables according to statements that are contained in the resource that is passed. -
createTablesBySqlSequence
-
removeComments
-