I have authored a c++ application that is useful in the creation of new Grails projects supporting the MariaDB relational database management system (RDBMS). The c++ program fulfills all the perfunctory requirements to utilize MariaDB via Grails.
-
- Create the Grails Project – This is accomplished by allowing the user to select a target for the Grails project.
Then the Grails create app command is issued inside the target for the Grails project.[codesyntax lang=”cpp”]grails create-app demo02a
[/codesyntax]
- Moodify the gradle build file to include the base definition for MariaDB.[codesyntax lang=”cpp”]
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client:2.7.4'
compile "org.grails.plugins:spring-security-core:4.0.0.RC2"
[/codesyntax]
After the gradle build is modified it must be compiled to activate the access to MariaDB.
[codesyntax lang=”bash”]cd /home/archman/workspace/grails/demo02a&& /usr/bin/grails compile
[/codesyntax]
- Select the Maria database – A dialog is displayed for the user and when double clicked one the desired database that database is selected.
- Update the yaml file to include the MariaDB data sources.[codesyntax lang=”cpp”]
--- grails: profile: web codegen: defaultPackage: demo02a gorm: reactor: # Whether to translate GORM events into Reactor events # Disabled by default for performance reasons events: false info: app: name: '@info.app.name@' version: '@info.app.version@'r grailsVersion: '@info.app.grailsVersion@' spring: jmx: unique-names: true main: banner-mode: "off" groovy: template: check-template-location: false devtools: restart: additional-exclude: - '*.gsp' - '**/*.gsp' - '*.gson' - '**/*.gson' - 'logback.groovy' - '*.properties' environments: development: management: endpoints: enabled-by-default: true web: base-path: '/actuator' exposure: include: '*' production: management: endpoints: enabled-by-default: false --- grails: mime: disable: accept: header: userAgents: - Gecko - WebKit - Presto - Trident types: all: '*/*' atom: application/atom+xml css: text/css csv: text/csv form: application/x-www-form-urlencoded html: - text/html - application/xhtml+xml js: text/javascript json: - application/json - text/json multipartForm: multipart/form-data pdf: application/pdf rss: application/rss+xml text: text/plain hal: - application/hal+json - application/hal+xml xml: - text/xml - application/xml urlmapping: cache: maxsize: 1000 controllers: defaultScope: singleton converters: encoding: UTF-8 views: default: codec: html gsp: encoding: UTF-8 htmlcodec: xml codecs: expression: html scriptlet: html taglib: none staticparts: none --- hibernate: cache: queries: false use_second_level_cache: false use_query_cache: false dataSource: driverClassName: org.mariadb.jdbc.Driver dialect: org.hibernate.dialect.MariaDBDialect username: bcs password: Pece007!amb url: jdbc:mariadb://localhost:3306/bcswebtools environments: development: dataSource: dbCreate: update url: jdbc:mariadb://localhost:3306/bcswebtools test: dataSource: dbCreate: update url: jdbc:h2:mem:testDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE production: dataSource: dbCreate: none url: jdbc:h2:./prodDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE properties: jmxEnabled: true initialSize: 5 maxActive: 50 minIdle: 5 maxIdle: 25 maxWait: 10000 maxAge: 600000 timeBetweenEvictionRunsMillis: 5000 minEvictableIdleTimeMillis: 60000 validationQuery: SELECT 1 validationQueryTimeout: 3 validationInterval: 15000 testOnBorrow: true testWhileIdle: true testOnReturn: false jdbcInterceptors: ConnectionState defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
[/codesyntax]
- Create a new domain class for the selected database.[codesyntax lang=”bash”]
grails create-domain-class ttd
[/codesyntax]The resulting newly generated class is listed below.
[codesyntax lang=”cpp”]package demo02a class Ttd { static constraints = { } }
[/codesyntax]
- Create the Grails Project – This is accomplished by allowing the user to select a target for the Grails project.
By using this tool the end user can create any Grails project that supports the Maria database with zero coding.
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.