Setting a default datasource

In the root of your project, there is a file called Application.bx. This is a BoxLang class which defines certain settings for all the files and folders underneath it. This makes those files and folders work together as one application, hence the name.

In the Application.bx file, make the following changes. Setting this.datasource defines a default datasource that all queries to the DB will use unless they are told specifically to use another one.

class {

    this.name = 'yourDatasourceName';
    this.dsource = 'yourDatasourceName';
    this.datasource = 'yourDatasourceName';
    this.sessionmanagement = 'true';

    public function onApplicationStart() {
        application.datasource = this.datasource;
    }
        
}

Lesson 2 of 3 - Connecting to a Database