Skip to content

DBConnection

Matt Baker edited this page Aug 18, 2020 · 7 revisions

Example

plugins {
  id "oe.espress.latte" version "<version>"
  id "base"
}    

import oe.espresso.latte.*

task createDB(type: CreateDatabase) {
    dbName = "sports2020"
    destDir = "${buildDir}"
    sourceDb = "/path/to/dlc/sports2020.db"
    largeFiles = true
}

task connectDB(type: DBConnection) {
    dependsOn createDB
    dbName = 'sports2020'
    dbDir = "${buildDir}"
    id = 'sports2020'
    singleUser = true
}

task compileCode(type: CompileAblTask) {
    dependsOn connectDB
 
    source('src/abl')
    include('**/*.p')

    dbConnections << 'sports2020'

    destinationDir = file("${buildDir}/compiled")
}

In your project, create a foo.p file in the src/abl folder.

// src/abl/foo.p
MESSAGE 'I am foo'.

This example creates a database, creates a DBConnection, and uses the created connection to compile code in src/abl.

Use the command ./gradlew compileCode to run this example.

If successful, there should be a foo.r in build/compiled of your project.

Properties

Attribute Required Description Default value
dbName Yes, if paramFile is not set Database physical name None
paramFile Yes, if dbName is not set Parameter file (-pf parameter). If paramFile is set and dbName is unset, paramFile is always in first position. If both paramFile and dbName are set, dbName is in first position and paramFile in second position. Don't define multiple database connections in a single paramFile, this can lead to unexpected behavior None
dbDir No Directory where database is physically located (relative to baseDir) None
dbPort No TCP port to connect to (-S parameter) None
protocol No Protocol to use (-N parameter) None
logicalName No Logical name for the database (-ld parameter) None
cacheFile No Name of the binary cache file (-cache parameter) None
dataService No Dataservice (-DataService parameter) None
dbType No Database type (Oracle, SQL Server, ...) (-dt parameter) None
hostName No Host name where the database resides (-H parameter) None
userName No Login (-U parameter) None
password No Password (-P parameter) None
readOnly No Open the database in read-only mode (-RO parameter) False
singleUser No Open the database in single-user mode (-1 parameter) False

Please refer to PCTConnection for more information.

Alias

Database alias' are handled through the alias function. You can add multiple alias' to a database connection by calling the function multiple times.


task connectDB(type: DBConnection) {
    dbName = 'sports2020'
    id = 'sports2020'
    alias 'sports2000'
    alias 'sports2k'
}