MariaDB: Connecting MariaDB with Groovy/Grails
This documentation is part of the Getting started guide. View the full guide here: How to get started with MariaDB.
👋 Welcome to Stackhero documentation
Stackhero provides a ready-to-use MariaDB cloud service designed for production workloads. You get:
- Unlimited connections and data transfers.
- Built-in phpMyAdmin web interface for database management.
- One-click updates for easy maintenance.
- High performance and strong security on private, dedicated infrastructure.
Launch a fully managed MariaDB instance in minutes. Stackhero handles setup, updates, and security so you can focus on your application. Learn more about MariaDB cloud hosting.
Here is an example of how you can configure your Grails application to connect to MariaDB:
dataSource {
pooled = true
driverClassName = "com.mysql.cj.jdbc.Driver"
dialect = org.hibernate.dialect.MySQL8Dialect
// SSL-specific properties
properties {
useSSL = true
requireSSL = true
verifyServerCertificate = true
sslMode = "REQUIRED"
}
}
environments {
production {
dataSource {
dbCreate = "none"
url = "jdbc:mysql://" + System.env.STACKHERO_MYSQL_HOST + ":" + System.env.STACKHERO_MYSQL_PORT + "/root?useSSL=true&requireSSL=true&verifyServerCertificate=true&sslMode=required" // Replace '/root' with your actual database name.
username = "root" // It is a good idea to create a dedicated user for your app.
password = System.env.STACKHERO_MYSQL_ROOT_PASSWORD // Consider creating a dedicated user.
properties {
maxActive = 50
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
numTestsPerEvictionRun = 3
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
validationQuery = "SELECT 1"
}
}
}
}