6.3.3.5. createDb
createDb
– the task of the CubaDbCreation
type which creates application database by executing the corresponding scripts. It is declared in the core module. Parameters:
-
dbms
– the DBMS type, specified as the stringhsql
,postgres
,mssql
, ororacle
. -
dbName
– the database name. -
dbUser
– the DBMS username. -
dbPassword
– the DBMS user password. -
host
– the DBMS host and port (optional) in thehost[:port]
format. If not specified,localhost
is used. -
connectionParams
- an optional connection parameters string which will be appended to the end of the connection URL. -
masterUrl
– the URL used to connect when creating the database. If not specified, the default value that depends on the DBMS type and thehost
parameter is used. -
dropDbSql
– the SQL command to delete the database. If not specified, the default value that depends on the DBMS type is used. -
createDbSql
– the SQL command to create a database. If not specified, the default value that depends on the DBMS type is used. -
driverClasspath
– the list of JAR files containing the JDBC driver. The items in the list are separated by ":" on Linux and by ";" on Windows. If not specified, the system uses the dependencies that are part of the current module’sjdbc
configuration. Explicit definition ofdriverClasspath
is necessary when using Oracle, because its JDBC driver is not available in the dependencies. -
oracleSystemPassword
– the SYSTEM user password for Oracle.
Example for PostgreSQL:
task createDb(dependsOn: assemble, description: 'Creates local database', type: CubaDbCreation) {
dbms = 'postgres'
dbName = 'sales'
dbUser = 'cuba'
dbPassword = 'cuba'
}
Example for MS SQL Server:
task createDb(dependsOn: assemble, description: 'Creates local database', type: CubaDbCreation) {
dbms = 'mssql'
dbName = 'sales'
dbUser = 'sa'
dbPassword = 'saPass1'
connectionParams = ';instance=myinstance'
}
Example for Oracle:
task createDb(dependsOn: assemble, description: 'Creates database', type: CubaDbCreation) {
dbms = 'oracle'
host = '192.168.1.10'
dbName = 'orcl'
dbUser = 'sales'
dbPassword = 'sales'
oracleSystemPassword = 'manager'
driverClasspath = "$tomcatDir/lib/ojdbc6.jar"
}