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 the Stackhero documentation!
Stackhero offers a ready-to-use MariaDB cloud solution that provides a host of benefits, including:
- Unlimited connections and transfers.
- phpMyAdmin web UI included.
- Effortless updates with just a click.
- Optimal performance and robust security powered by a private and dedicated VM.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's MariaDB cloud hosting solution!
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"
}
}
}
}